R语言可视化(八)

ggplot2散点图可视化

数据读取

library(ggplot2)

df<-read.csv(“Data.csv”, header = TRUE)

散点可视化

library(RColorBrewer)

ggplot(df, aes(x=SOD,y=tau,fill=Class)) + 
  geom_point(shape=21,size=3,colour="black",stroke=0.25) +
  scale_fill_brewer(palette='Set1')+
  theme(
    text=element_text(size=14,color="black"),
    plot.title=element_text(size=14,family="myfont",face="bold.italic",hjust=.5,color="black"),
    legend.background = element_blank(),
    legend.position=c(0.8,0.15)
  )

在这里插入图片描述

library(viridis)
ggplot(df, aes(x=SOD,y=tau,fill=Class)) + 
  geom_point(shape=21,size=3,colour="black",stroke=0.25) +
  scale_fill_viridis(option = "plasma",discrete =TRUE)+
  theme(
    text=element_text(size=14,color="black"),
    plot.title=element_text(size=14,family="myfont",face="bold.italic",hjust=.5,color="black"),
    legend.background = element_blank(),
    legend.position=c(0.8,0.15)
  )

在这里插入图片描述

library(wesanderson)
ggplot(df, aes(x=SOD,y=tau,fill=Class)) + 
  geom_point(shape=21,size=3,colour="black",stroke=0.25) +
  scale_fill_manual(values=wes_palette("Darjeeling1")[c(1,3,5)])+
  theme(
    text=element_text(size=14,color="black"),
    plot.title=element_text(size=14,family="myfont",face="bold.italic",hjust=.5,color="black"),
    legend.background = element_blank(),
    legend.position=c(0.8,0.15)
  )

在这里插入图片描述

ggplot(df, aes(x=SOD,y=tau,fill=Class)) + 
  geom_point(shape=21,size=3,colour="black",stroke=0.25) +
  scale_fill_manual(values=c("#E7298A","#66A61E","#E6AB02"))+
  theme(
    legend.background = element_blank(),
    legend.position=c(0.8,0.15)
  )

在这里插入图片描述

ggplot(df, aes(x = tau, y = SOD, fill=age)) +
  geom_point(shape=21,size=4,colour="black",alpha=0.95) +
  scale_fill_distiller(palette="RdYlBu")+
  theme(
    text=element_text(size=15,color="black"),
    plot.title=element_text(size=15,family="myfont",face="bold.italic",hjust=.5,color="black"),
    legend.background = element_blank(),
    legend.position=c(0.85,0.2)
  )

在这里插入图片描述

ggplot(df, aes(x = tau, y = SOD, fill=age)) +
  geom_point(shape=21,size=4,colour="black",alpha=0.95) +
  scale_fill_viridis(option = "viridis",discrete =FALSE)+
  theme(
    text=element_text(size=15,color="black"),
    plot.title=element_text(size=15,family="myfont",face="bold.italic",hjust=.5,color="black"),
    legend.background = element_blank(),
    legend.position=c(0.85,0.2)
  )

在这里插入图片描述

ggplot(df, aes(x = tau, y = SOD, fill=age)) +
  geom_point(shape=21,size=4,colour="black",alpha=0.95) +
  scale_fill_gradient2(low="#00A08A",mid="white",high="#FF0000",midpoint = mean(df$age))+
  theme(
    text=element_text(size=15,color="black"),
    plot.title=element_text(size=15,family="myfont",face="bold.italic",hjust=.5,color="black"),
    legend.background = element_blank(),
    legend.position=c(0.85,0.2)
  )

在这里插入图片描述

ggplot(df, aes(x = tau, y = SOD, fill=age)) +
  geom_point(shape=21,size=4,colour="black",alpha=0.95) +
  scale_fill_gradientn(colors= terrain.colors(10))+
  theme(
    text=element_text(size=15,color="black"),
    plot.title=element_text(size=15,family="myfont",face="bold.italic",hjust=.5,color="black"),
    legend.background = element_blank(),
    legend.position=c(0.85,0.2)
  )

在这里插入图片描述

参考资料1:https://github.com/EasyChart/Beautiful-Visualization-with-R/

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值