每边有 2 个 y 轴和不同比例的 ggplot [英] ggplot with 2 y axes on each side and different scales
问题描述
我需要在一个图表中绘制一个显示计数的条形图和一个显示速率的折线图,我可以分别做这两个,但是当我把它们放在一起时,我会缩放第一层(即 geom_bar
) 与第二层(即 geom_line
)重叠.
I need to plot a bar chart showing counts and a line chart showing rate all in one chart, I can do both of them separately, but when I put them together, I scale of the first layer (i.e. the geom_bar
) is overlapped by the second layer (i.e. the geom_line
).
我可以将 geom_line
的轴向右移动吗?
Can I move the axis of the geom_line
to the right?
推荐答案
有时客户需要两个 y 刻度.给他们有缺陷"的演讲往往毫无意义.但我确实喜欢 ggplot2 坚持以正确的方式做事.我确信 ggplot 实际上是在教育普通用户正确的可视化技术.
Sometimes a client wants two y scales. Giving them the "flawed" speech is often pointless. But I do like the ggplot2 insistence on doing things the right way. I am sure that ggplot is in fact educating the average user about proper visualization techniques.
也许您可以使用 faceting 和 scale free 来比较两个数据系列?- 例如看这里:https://github.com/hadley/ggplot2/wiki/Align-two-plots-on-a-page
Maybe you can use faceting and scale free to compare the two data series? - e.g. look here: https://github.com/hadley/ggplot2/wiki/Align-two-plots-on-a-page
这篇关于每边有 2 个 y 轴和不同比例的 ggplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!