ggplot,每侧有2个y轴,并且比例不同 [英] ggplot with 2 y axes on each side and different scales

查看:288
本文介绍了ggplot,每侧有2个y轴,并且比例不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在一张图表中绘制一个条形图,显示计数和折线图,所有这些都可以分别进行,但是当我将它们放在一起时,便可以缩放第一层(即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.

也许您可以使用构面和自由缩放来比较这两个数据系列? -例如看这里: https://github.com/hadley/ggplot2/wiki/Align-two-plots-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

这篇关于ggplot,每侧有2个y轴,并且比例不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆