ggplot 不绘制直方图
ggplot not ploting histogram
我正在尝试根据以下数据(片段)绘制镜像直方图:
x 轴上 x 从 0 到 150(变量 Ilhavo 和 VNTelha-Maia 的范围)在 10 个子组中,“双”y 轴上是每个子组的次数(horas) Ilhavo 和 VNTelha-Maia 下的编号重复。
基本上我想得到这样的东西:
但是,无论我做什么,我似乎都无法创建它。
这是我尝试过的方法:
library(ggplot2)
library(readxl)
p <- ggplot(QualidadeARO3, aes(x=Ilhavo) ) +
geom_histogram( breaks=seq(0, 150, by=10), aes(x = Ilhavo , y = ..horas..), fill="#69b3a2" ) +
geom_label( aes(x=Ilhavo, y=horas, label="Ilhavo"), color="#69b3a2") +
geom_histogram(breaks=seq(0, 150, by=10), aes(x = VNTelha-Maia, y = -..horas..), fill= "#404080") +
geom_label( aes(x=VNTelha-Maia, y=horas, label="VN Telha"), color="#404080") +
xlab("microgramas/metro cúbico")
但是没有任何反应。有帮助吗?
像这样:
ggplot(df, aes(x=x) ) +
geom_histogram(breaks=seq(0, 150, by=10), aes(x = Ilhavo, y = ..density..), fill="#69b3a2" ) +
geom_label( aes(x=100, y=0.05, label="Ilhavo"), color="#69b3a2") +
geom_histogram(breaks=seq(0, 150, by=10), aes(x = VNTelha_Maia, y = -..density..), fill= "#404080") +
geom_label( aes(x=100, y=-0.05, label="VNTelha_Maia"), color="#404080") +
theme_bw()
我正在尝试根据以下数据(片段)绘制镜像直方图:
x 轴上 x 从 0 到 150(变量 Ilhavo 和 VNTelha-Maia 的范围)在 10 个子组中,“双”y 轴上是每个子组的次数(horas) Ilhavo 和 VNTelha-Maia 下的编号重复。
基本上我想得到这样的东西:
但是,无论我做什么,我似乎都无法创建它。
这是我尝试过的方法:
library(ggplot2)
library(readxl)
p <- ggplot(QualidadeARO3, aes(x=Ilhavo) ) +
geom_histogram( breaks=seq(0, 150, by=10), aes(x = Ilhavo , y = ..horas..), fill="#69b3a2" ) +
geom_label( aes(x=Ilhavo, y=horas, label="Ilhavo"), color="#69b3a2") +
geom_histogram(breaks=seq(0, 150, by=10), aes(x = VNTelha-Maia, y = -..horas..), fill= "#404080") +
geom_label( aes(x=VNTelha-Maia, y=horas, label="VN Telha"), color="#404080") +
xlab("microgramas/metro cúbico")
但是没有任何反应。有帮助吗?
像这样:
ggplot(df, aes(x=x) ) +
geom_histogram(breaks=seq(0, 150, by=10), aes(x = Ilhavo, y = ..density..), fill="#69b3a2" ) +
geom_label( aes(x=100, y=0.05, label="Ilhavo"), color="#69b3a2") +
geom_histogram(breaks=seq(0, 150, by=10), aes(x = VNTelha_Maia, y = -..density..), fill= "#404080") +
geom_label( aes(x=100, y=-0.05, label="VNTelha_Maia"), color="#404080") +
theme_bw()