用GGPLOT绘制负面直方图
我从同一数据框架中绘制两个系列。其中一个具有负值。
p_change <- ggplot(dx, aes(fill=Group)) +
geom_histogram(aes(x=posvalues), binwidth=1) +
geom_histogram(aes(x=negvalues), binwidth=1) +
xlim(0, 15) +
ylim(-25, 25) +
xlab('Number of tokens') +
theme(
legend.position = "right",
text=element_text(size = 19)
)
p_change
我希望将第二个直方图绘制在负y轴上。
I plot two series from the same dataframe. One of them has negative values.
p_change <- ggplot(dx, aes(fill=Group)) +
geom_histogram(aes(x=posvalues), binwidth=1) +
geom_histogram(aes(x=negvalues), binwidth=1) +
xlim(0, 15) +
ylim(-25, 25) +
xlab('Number of tokens') +
theme(
legend.position = "right",
text=element_text(size = 19)
)
p_change
I would like the second histogram to be plotted on the negative y-axis.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试这个。 IMO更有意义地将负值绘制在Xaxis上。
类的东西来完成使用Yaxis的解决方案
可以使用
You can try this one. IMO it makes more sense that the negative values are plotted on the xaxis.
The solution with the yaxis can be done using something like