ggplot自带主题设置

theme_bw()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_bw()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_classic()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_classic()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

theme_dark()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_dark()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_get()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_get()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_gray()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_gray()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_grey()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_grey()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_light()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_light()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_linedraw()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_linedraw()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_minimal()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_minimal()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_replace()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_replace()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_test()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_test()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

theme_void()

library(tidyverse)
library(ggsci)
library(gghalves)
ggplot(data = iris)+
  geom_half_violin(aes(x = Species,y = Sepal.Width,fill = Species,color = Species),side = "r",alpha = 0.8,trim = F,adjust = 1.5,position = position_nudge(x = 0.1))+
  geom_boxplot(aes(x = Species,y = Sepal.Width,fill = Species),width = 0.1,alpha = 0.75,size = 0.8,position = position_dodge(0.75))+
  geom_point(aes(x = as.numeric(Species)-0.2,y = Sepal.Width,fill = Species),shape = 21,size = 3,alpha = 0.75,position = position_jitter(width = 0.1))+
  theme_void()+  #### 主题
  theme(plot.margin = unit(x = c(0.3,0.3,0.2,0.2),units = "cm"))+
  theme(legend.text = element_text(size = 14, colour = "black"))+
  theme(plot.title = element_text(size = 25,hjust = 0.5, angle = 0))+
  theme(axis.title.x = element_text(size = 16, face = "bold", colour = "black"),
        axis.title.y = element_text(size = 16, face = "bold", colour = "black"),
        axis.text.x = element_text(size = 12, face = "bold", colour = "black",hjust = 0.5),
        axis.text.y = element_text(size = 12, face = "bold",colour = "black"))+
  theme(legend.position = 'none')

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编码农夫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值