全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2845 1
2015-08-27
Rplot03.png Rplot01.png
#geom_vline 图注标记:垂直线的画法
library(ggplot2)
library(ggthemes)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + geom_vline(xintercept = 5)
p + geom_vline(xintercept = 1:5)
wt
mtcars$wt
p + geom_vline(xintercept = 1:5, colour="green", linetype = "longdash")
p + geom_vline(aes(xintercept = wt))
p + geom_vline(aes(xintercept = wt)) + coord_equal()
p + geom_vline(aes(xintercept = wt)) + coord_flip()
p + geom_vline(aes(xintercept = wt)) + coord_polar()+theme_wsj()
p2 <- p + aes(colour = factor(cyl))
p2 + geom_vline(xintercept = 15)
p <- qplot(mpg, wt, data=mtcars, facets = vs ~ am)
vline.data <- data.frame(z = c(15, 20, 25, 30), vs = c(0, 0, 1, 1), am = c(0, 1, 0, 1))
library(ggthemes)
p + geom_vline(aes(xintercept = z), vline.data)+theme_wsj()

#geom_hline 图注标记:水平线的画法
p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point()

p + geom_hline(aes(yintercept=mpg))
p + geom_hline(yintercept=20)
p + geom_hline(yintercept=seq(10, 30, by=5))+theme_wsj()

# With coordinate transforms
p + geom_hline(aes(yintercept=mpg)) + coord_equal()
p + geom_hline(aes(yintercept=mpg)) + coord_flip()
p + geom_hline(aes(yintercept=mpg)) + coord_polar()

# To display different lines in different facets, you need to
# create a data frame.
p <- qplot(mpg, wt, data=mtcars, facets = vs ~ am)

hline.data <- data.frame(z = 1:4, vs = c(0,0,1,1), am = c(0,1,0,1))
p + geom_hline(aes(yintercept = z), hline.data)
unemp+geom_rect(aes(NULL,NULL,xmin=start,xmax=end,fill=party),ymin=yrng[1],ymax=yrng[2],
                data=presidential,alpha=0.2)+scale_fill_manual(values=c("blue","red"))





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-8-27 21:50:08
qllyes 发表于 2015-8-27 20:49
#geom_vline 图注标记:垂直线的画法
library(ggplot2)
library(ggthemes)
只能看懂一点点
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群