R绘图_ggplot2图形参数之翻转和反转[9]

2020-03-22  本文已影响0人  谢俊飞
火狐截图_2020-02-11T08-36-22.554Z.png

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()
上一篇 下一篇

猜你喜欢

热点阅读