- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个简单的两个变量数据框,第三个变量作为一个因素
DF <- data.frame(Depth = c(8.6, 19.6, 42.6, 60.6, 79.4, 101.4, 121.4, 137.6, 163, 180),
Rb = c(103, 59, 99, 53, 107, 87, 52, 33, 105, 49),
Litho = as.factor(c(1,2,1,2,1,1,2,2,1,2)))
geom_col()
.我想将 Rb 绘制为深度的函数,因此深度应该是离散变量。但是,当我绘制使用
ggplot (DF, aes(x=Depth, y=Rb))+
geom_col()
ggplot (DF, aes(x=Rb, y=Depth))+
geom_col()
geom_bar(stat = 'identity')
,但它仍然是同样的问题。
ggplot (DF, aes(x=Depth, y=Rb/10, fill=Litho)) +
geom_bar(stat='identity') +
labs(x="Depth", y="Rb") +
scale_x_continuous (trans = "reverse") +
scale_y_continuous (position = "right") +
coord_flip()
最佳答案
您可以在 geom_col()
中强制定向与 "orientation"
争论。
来自 ?geom_col
:
orientation
The orientation of the layer. The default (NA
) automatically determines the orientation from the aesthetic mapping. In the rare event that this fails it can be given explicitly by settingorientation
to either"x"
or"y"
.[
geom_col
] treats each axis differently and, thus, can thus have two orientations. Often the orientation is easy to deduce from a combination of the given mappings and the types of positional scales in use. Thus, ggplot2 will by default try to guess which orientation the layer should have. Under rare circumstances, the orientation is ambiguous and guessing may fail. In that case the orientation can be specified directly using theorientation
parameter, which can be either"x"
or"y"
. The value gives the axis that the geom should run along,"x"
being the default orientation you would expect for the geom.
ggplot (DF, aes(x = Depth, y = Rb)) +
geom_col(orientation = "x")
关于r - geom_col 分配了错误的自变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62007106/
在使用 geom_col 时,可以选择更改 fill 和 col是否可以在 geom_col 中更改条的宽度 - 就像下面的最后一行? dt <- data.table(diamonds) [ , .
我对 ggplot 有疑问。数据: df <- structure(list(date = structure(c(1499050800, 1499054400, 1499058000, 149906
我有一个简单的两个变量数据框,第三个变量作为一个因素 DF <- data.frame(Depth = c(8.6, 19.6, 42.6, 60.6, 79.4, 101.4, 121.4, 137
我是 R 新手。我在以下 geom_col 图表中的 geom_text 元素的排序方面遇到问题。 我相信它与 position =position_dodge2(preserve = "single
我试图理解其他结果,但我做不到。这是我的数据集: > HIST # A tibble: 1,071 x 16 Ano Leilao Fonte UF Vend
library(tidyverse) library(lubridate) date % t() %>% as.data.frame() %>% rownames_to_column('var')
我想在我的 geom_col 图中仅在模态条(最高峰值)上方放置一个标签,给出 x 轴值(CAG)。这是一个例子,但我只能让它标记每个峰。 x <- seq(-20, 20, by = .1) y <
我查看了无数个地方,但实际上没有一个地方为这两个 geom 提供了所有可用的 position。我知道有 stack(将一个放在另一个之上),dodge(使每个组并排成小簇),identity (将它
这个问题在这里已经有了答案: Manually setting group colors for ggplot2 (1 个回答) 关闭 3 年前。 我正在尝试使用手动填充颜色制作条形图。现在我有 5
我正在尝试更改 geom_col 图的图例形状。默认情况下,图例是方形的,我想更改为圆形(或三角形或其他任何东西)。由于颜色由 fill 控制,我认为覆盖这个参数应该可以解决问题: library(g
我编写了以下函数来制作自定义堆叠图: stacked_plot % mutate(!!date_col := floor_date(!!date_col, unit = !!date_un
有时,我需要为 geom_bar()/geom_col() 条(即黑白打印)使用某种图案或纹理。例如,某些人可能难以查看以下内容: library(ggplot2) library(dplyr, wa
我已经解决了相关问题,但这些答案并没有解决我的标签没有躲避以匹配 geom_col 条的问题: 数据 x % mutate(Month=format(unified_date,'%b')) %>%
我已经解决了相关问题,但这些答案并没有解决我的标签没有躲避以匹配 geom_col 条的问题: 数据 x % mutate(Month=format(unified_date,'%b')) %>%
我尝试添加显示给定 x 类别的 y 值总和的数据标签。这是我使用的代码: library(ggplot2) gg <- ggplot(vgsales, aes(x = Genre, y = Globa
请找我的资料p以下。我必须包含 100 个样本才能重现错误。 问题:为什么是 geom_text打印始终居中对齐 geom_col - 例如 21 和 28 在 All在右边 SSA -方面?我试过调
边距中的条形图似乎选择了最大的面,而不是像我预期的那样将它们相加。 它们不应该堆积在边缘吗? 这是一个错误吗? 关于如何更改 geom_col/geom_bar/position 设置或 stat_f
这个问题在这里已经有了答案: Showing data values on stacked bar chart in ggplot2 (2 个回答) 4年前关闭。 我想在 geom_col 中放置相应
我正在使用 geom_col 创建一个包含条形图的图表,并使用 gem_point(线)将性能与“基准”进行比较。性能指标属于不同的域,因此我使用 facet_wrap 以可视方式将域分成组,以便于查
我正在使用 geom_col 创建一个包含条形图的图表,并使用 gem_point(线)将性能与“基准”进行比较。性能指标属于不同的域,因此我使用 facet_wrap 以可视方式将域分成组,以便于查
我是一名优秀的程序员,十分优秀!