[英]Duplicating Discrete Axis in ggplot2
The development version of ggplot2 (2.1.0.9001) provides a nice shorthand for creating a secondary axis that is a duplication of the primary axis if the original axis is continuous: ggplot2 (2.1.0.9001) 的开发版本提供了一个很好的速记来创建一个辅助轴,如果原始轴是连续的,则该辅助轴是主轴的重复:
devtools::install_github("hadley/ggplot2")
library(ggplot2)
ggplot(mpg, aes(displ, cyl)) +
geom_point() +
scale_y_continuous(
sec.axis = dup_axis()
)
How can a discrete axis be duplicated?如何复制离散轴?
ggplot(mpg, aes(displ, factor(cyl))) +
geom_point() +
...?
The switch_axis_position is now deprecated, and in fact is gone. switch_axis_position 现在已弃用,实际上已经消失了。 Issues with ggdraw since ggplot2 update
自 ggplot2 更新以来 ggdraw 的问题
Outdated material: The cowplot library
has
used to have that that facility:过时的材料:cowplot 库
曾经
拥有该设施:
library(cowplot)
gpv <- ggplot(mpg, aes(displ, factor(cyl))) +
geom_point()
ggdraw( switch_axis_position( gpv, axis="y", keep="y"))
Don't forget that you need to print
grid-based graphics when sending to a file:不要忘记在发送到文件时需要
print
基于网格的图形:
png()
print(ggdraw(switch_axis_position(gpv, axis="y", keep="y")) )
dev.off()
#quartz
# 2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.