R语言可视化(十二)

ggplot2折线图

> library(ggplot2)
> 
> N<-20 df1 <- data.frame(x=sort(rnorm(N)),y=sort(rnorm(N))) df2 <-
> data.frame(x=df1$x+0.1*rnorm(N),y=df1$y+0.1*rnorm(N))

所有图层共享数据源和美学映射参数

> ggplot(df1,aes(x,y,colour=x+y))+   geom_line(size=1)+  
> geom_point(shape=16,size=5)+  
> guides(color=guide_colorbar(title="Point\nLine"))

在这里插入图片描述
#所有图层仅共享数据源

ggplot(df1,aes(x,y))+
  geom_line(aes(colour=x+y),size=1)+    
  geom_point(aes(fill=x+y),color="black",shape=21,
             size=5)+
  scale_fill_distiller(name="Point",palette="YlOrRd")+
  scale_color_distiller(name="Line",palette="Blues")

在这里插入图片描述

#各图层对象均使用独立的数据源与美学映射参数

ggplot()+
  geom_line(aes(x,y,colour=x+y),df1,size=1)+    
  geom_point(aes(x,y,fill=x+y),df2,color="black",
             shape=21, size=5)+
  scale_fill_distiller(name="Point",palette="YlOrRd")+
  scale_color_distiller(name="Line",palette="Blues")

在这里插入图片描述
参考资料1:https://github.com/EasyChart/Beautiful-Visualization-with-R/

参考资料2:https://blog.csdn.net/tandelin/article/details/87719623

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值