由2个y轴组成的多个并排条形图(ggplot或base R)
具有2个y轴的多个并排条形图的说明 我想使用以下提供的数据,为两个变量生成一个条形图(见下文):-由2个y轴组成的多个并排条形图(ggplot或base R),r,ggplot2,graphics,bar-chart,R,Ggplot2,Graphics,Bar Chart,具有2个y轴的多个并排条形图的说明 我想使用以下提供的数据,为两个变量生成一个条形图(见下文):- 一个用于T.max.open,它与open\u站点列一起 一个用于T.max.CAOPORY,它与_树下的列一起 x轴应命名为地形(即人工地表,裸土,草,凋落物和灌木丛,位于开阔地和树下的两列中) 每个地形组应该有两个相邻的条形图,代表不同植被类型在开阔地(开阔地)和树冠下(树木下)的温度范围 我不能使用一个y轴,因为我想显示树冠下方的温度(y轴1-T.max.canopy)和开放场地(y轴2-T
structure(list(Under_Tree = structure(c(2L, 2L, 2L, 3L, 1L, 3L,
2L, 2L, 2L, 3L, 1L, 3L, 2L, 2L, 3L, 1L, 3L, 2L, 2L, 3L), .Label = c("Artificial_Surface",
"Litter", "Undergrowth"), class = "factor"), Open_Site = structure(c(2L,
3L, 1L, 3L, 2L, 2L, 2L, 2L, 3L, 1L, 3L, 2L, 2L, 3L, 1L, 3L, 2L,
2L, 3L, 1L), .Label = c("Artificial_Surface", "Litter", "Undergrowth"
), class = "factor"), T.max.canopy = c(10, 14, 11.4, 7.7, 23.8,
12.9, 8, 15, 18.3, 9, 22.7, 12, 24.9, 11.2, 7.9, 4.5, 5.6, 13.7,
15.9, 16.4), T.max.open = c(8, 15, 18.3, 9, 22.7, 12, 17.4, 13,
17.9, 16.6, 14.6, 18.3, 27.5, 14.1, 17.5, 15.4, 13, 15.1, 15.1,
19.7)), .Names = c("Under_Tree", "Open_Site", "T.max.canopy",
"T.max.open"), class = "data.frame", row.names = c(NA, -20L))
很抱歉,雨落在你的树冠上,但我觉得条形图并不是你美丽数据的最佳表现。在我看来,它们最好用散点图来表示,再加上刻面和颜色,故事就可以非常有效地讲出来。看看你是否同意:
xy <- structure(list(Under_Tree = structure(c(2L, 2L, 2L, 3L, 1L, 3L,
2L, 2L, 2L, 3L, 1L, 3L, 2L, 2L, 3L, 1L, 3L, 2L, 2L, 3L), .Label = c("Artificial_Surface",
"Litter", "Undergrowth"), class = "factor"), Open_Site = structure(c(2L,
3L, 1L, 3L, 2L, 2L, 2L, 2L, 3L, 1L, 3L, 2L, 2L, 3L, 1L, 3L, 2L,
2L, 3L, 1L), .Label = c("Artificial_Surface", "Litter", "Undergrowth"
), class = "factor"), T.max.canopy = c(10, 14, 11.4, 7.7, 23.8,
12.9, 8, 15, 18.3, 9, 22.7, 12, 24.9, 11.2, 7.9, 4.5, 5.6, 13.7,
15.9, 16.4), T.max.open = c(8, 15, 18.3, 9, 22.7, 12, 17.4, 13,
17.9, 16.6, 14.6, 18.3, 27.5, 14.1, 17.5, 15.4, 13, 15.1, 15.1,
19.7)), .Names = c("Under_Tree", "Open_Site", "T.max.canopy",
"T.max.open"), class = "data.frame", row.names = c(NA, -20L))
library(ggplot2)
library(tidyr)
library(Hmisc)
xyg <- gather(xy, key = tree, value = microlocation, -T.max.canopy, -T.max.open)
xyg <- gather(xyg, key = canopyside, value = temperature, -tree, -microlocation)
ggplot(xyg, aes(x = microlocation, y = temperature, color = canopyside)) +
theme_bw() +
geom_point(alpha = 0.75) +
scale_color_brewer(palette = "Set1") +
stat_summary(fun.data = "mean_cl_boot", color = "black", size = 1, alpha = 0.5) +
facet_wrap(~ tree)
xy当值在同一范围内时,为什么需要两个y轴?因为T.max.open(开放场地的温度)和T.max.corporation(树冠下的温度)是两个独立的测量值,我想在同一个图上加以说明。因此,有可能检测到两种小气候中的温度变化之间的关系,以及变化的温度是否会影响检测到的植被类型的组成。如果你能帮忙,非常感谢