R 更改ggplot中变量名称的字体大小

R 更改ggplot中变量名称的字体大小,r,ggplot2,R,Ggplot2,我无法增加使用ggplot实现的图形中变量名称的字体大小 我试图在ggplot代码中包含这些代码,但未成功: theme(text = element_text(size=20)) theme(axis.text=element_text(size=20)) theme(axis.title=element_text(size=14)) theme_grey(base_size = 20) geom_text(size=20) 我的代码是: library(ggplot2) library(r

我无法增加使用ggplot实现的图形中变量名称的字体大小

我试图在ggplot代码中包含这些代码,但未成功:

theme(text = element_text(size=20))
theme(axis.text=element_text(size=20))
theme(axis.title=element_text(size=14))
theme_grey(base_size = 20)
geom_text(size=20)
我的代码是:

library(ggplot2)
library(reshape2)
dataplot <- read.csv("/Documents/R.csv",header=T,sep=";")
dataPlotMelt <- melt(data = dataplot, id.vars = c("variable"),variable.name = "Method",value.name = "SMD")
varNames <- as.character(dataplot$variable)
dataPlotMelt$variable <- factor(dataPlotMelt$variable,levels = varNames)
ggplot(data=dataPlotMelt,mapping=aes(x=variable,y=SMD,group=Method, color=Method))+
  ylab("Standardizedmeandifference(%)")+
  xlab("") +
  geom_point(aes(shape=Method),size=2) +
  geom_hline(yintercept=15,color="black",size=0.1,linetype="dashed") + 
  geom_hline(yintercept=-15,color="black",size=0.1,linetype="dashed") + 
  coord_flip() + 
  theme(axis.text.x=element_blank()) +
  scale_y_continuous(breaks=c(-65,-15,15,105)) + 
  theme_bw() + 
  theme(legend.text=element_text(size=12)) +
  theme(legend.title=element_blank(),legend.key=element_blank()) +
  scale_colour_manual(values=c("grey","black"))
库(ggplot2)
图书馆(E2)
数据图
谢谢你Richard给我答案。
正如你所建议的,我在
theme\u bw

我还使用命令
theme(panel.grid.minor=element\u blank())抑制了无用的垂直线。

以下是ggplot的新代码:

ggplot(data = dataPlotMelt, mapping = aes(x = variable, y = SMD,group = Method, 
  color = Method)) +
  ylab("Standardized mean difference (%)") + xlab("") +
  geom_point(aes(shape = Method),size=2) +
  geom_hline(yintercept = 15, color = "black", size = 0.1, linetype = "dashed") + 
  geom_hline(yintercept = -15, color = "black", size = 0.1, linetype = "dashed") +
  coord_flip() + 
  theme(axis.text.x = element_blank()) +
  scale_y_continuous(breaks=c(-65,-15,0,15,105)) +
  theme_bw() + theme(legend.text = element_text(size=13)) + 
  scale_colour_manual(values= c("grey","black")) +
  theme(axis.text.y = element_text(size=12)) + 
  theme(axis.title.x = element_text(size=13)) + 
  theme(panel.grid.minor = element_blank()) + 
  theme(legend.title = element_blank(), legend.key=element_blank())
谢谢你Richard给我答案。 正如你所建议的,我在
theme\u bw

我还使用命令
theme(panel.grid.minor=element\u blank())抑制了无用的垂直线。

以下是ggplot的新代码:

ggplot(data = dataPlotMelt, mapping = aes(x = variable, y = SMD,group = Method, 
  color = Method)) +
  ylab("Standardized mean difference (%)") + xlab("") +
  geom_point(aes(shape = Method),size=2) +
  geom_hline(yintercept = 15, color = "black", size = 0.1, linetype = "dashed") + 
  geom_hline(yintercept = -15, color = "black", size = 0.1, linetype = "dashed") +
  coord_flip() + 
  theme(axis.text.x = element_blank()) +
  scale_y_continuous(breaks=c(-65,-15,0,15,105)) +
  theme_bw() + theme(legend.text = element_text(size=13)) + 
  scale_colour_manual(values= c("grey","black")) +
  theme(axis.text.y = element_text(size=12)) + 
  theme(axis.title.x = element_text(size=13)) + 
  theme(panel.grid.minor = element_blank()) + 
  theme(legend.title = element_blank(), legend.key=element_blank())

确保在
theme\u bw
之后使用
theme
确保在
theme\u bw
之后使用
theme