I have a ggplot code and I wanted to change the size of labels for x-axis and y-axis.
我有一个ggplot代码,我想改变x轴和y轴的标签大小。
the code:
代码:
df.m <- melt(df, names(df)[2:3], names(df)[1])
df.m$Results <- factor(df.m$Results)
df.m$HMn25_30.h <- strptime(as.character(df.m$HMn25_30.h), format = "%Y-%m-%d %H:%M:%S")
p <- ggplot(df.m, aes(x = HMn25_30.h, y = value, group = variable, color = variable))
p <- p + scale_shape_manual(values=c(20,22))
p <- p + geom_point(aes(shape = Results), cex=4, color= "blue3")
p <- p + geom_line(size=.8)
p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1, size=13,color="darkred"))
p <- p + scale_color_manual(values=c("Red"))
p <- p + ylim(-1,8)
p <- p + xlab('Date and Time')
p <- p + ylab('Temperature')
p <- p + ggtitle("Temporal Outliers of Node 25 ") + theme(plot.title = element_text(lineheight=3, face="bold", color="black", size=29))
p
In other words "Temperature" and "Date and Time" font and size should be changed.
换句话说,应该更改“温度”和“日期和时间”字体和大小。
1 个解决方案
#1
36
You can apply different options of theme
:
您可以应用主题的不同选项:
p <- ggplot(df.m, aes(x = HMn25_30.h, y = value, group = variable, color = variable))
p <- p + scale_shape_manual(values=c(20,22))
p <- p + geom_point(aes(shape = Results), cex=4, color= "blue3")
p <- p + geom_line(size=.8)
p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1, size=13,color="darkred"))
p <- p + scale_color_manual(values=c("Red"))
p <- p + ylim(-1,8)
p <- p + theme_bw()
p <- p + xlab('Date and Time')
p <- p + ylab('Temprature')
p <- p + ggtitle("Temporal Outliers of Node 25 ") + theme(plot.title = element_text(lineheight=3, face="bold", color="black", size=29))
p <- p + labs(x = "Date-Time ", y = "Temprature ")
p <- p + theme(axis.title.y = element_text(size = rel(1.8), angle = 90))
p <- p + theme(axis.title.x = element_text(size = rel(1.8), angle = 00))
p
#1
36
You can apply different options of theme
:
您可以应用主题的不同选项:
p <- ggplot(df.m, aes(x = HMn25_30.h, y = value, group = variable, color = variable))
p <- p + scale_shape_manual(values=c(20,22))
p <- p + geom_point(aes(shape = Results), cex=4, color= "blue3")
p <- p + geom_line(size=.8)
p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1, size=13,color="darkred"))
p <- p + scale_color_manual(values=c("Red"))
p <- p + ylim(-1,8)
p <- p + theme_bw()
p <- p + xlab('Date and Time')
p <- p + ylab('Temprature')
p <- p + ggtitle("Temporal Outliers of Node 25 ") + theme(plot.title = element_text(lineheight=3, face="bold", color="black", size=29))
p <- p + labs(x = "Date-Time ", y = "Temprature ")
p <- p + theme(axis.title.y = element_text(size = rel(1.8), angle = 90))
p <- p + theme(axis.title.x = element_text(size = rel(1.8), angle = 00))
p