Rotate a plot: flip and reverse
ggplot2:旋转图:翻转和反转
本R教程的目的是描述如何旋转使用R软件和ggplot2软件包创建的图。
根据代码运行如下:
rm(list = ls())
# Horizontal plot : coord_flip()
library(ggplot2)
# Basic box plot
bp <- ggplot(PlantGrowth, aes(x=group, y=weight))+
geom_boxplot()
bp
# Horizontal box plot
bp + coord_flip()
set.seed(1234)
# Basic histogram
hp <- qplot(x=rnorm(200), geom="histogram")
hp
# Horizontal histogram
hp + coord_flip()
# Reverse y axis
# Basic histogram
hp
# Y axis reversed
hp + scale_y_reverse()
网友评论