如何增加ggplot2中的轴标签和图例大小?

时间:2018-07-25 14:28:12

标签: r ggplot2

我希望轴标签和图例看起来更大,并且我想增加字体大小

我的代码:

  

g = df.groupby('group').amount df['max'] = g.transform('max') df['min'] = g.transform('min') df['lag1'] = g.shift() df['lag2'] = g.shift(2) group year amount max min lag1 lag2 0 1 2007 2.0 7.0 2.0 NaN NaN 1 1 2008 4.0 7.0 2.0 2.0 NaN 2 1 2009 NaN 7.0 2.0 4.0 2.0 3 1 2010 7.0 7.0 2.0 NaN 4.0 4 2 2006 8.0 12.0 8.0 NaN NaN 5 2 2007 10.0 12.0 8.0 8.0 NaN 6 2 2008 12.0 12.0 8.0 10.0 8.0

1 个答案:

答案 0 :(得分:1)

您可以使用theme来访问titlelegend字体大小,如下所示。

library(ggplot2)
library(scales)
ggplot(data.frame(x = c(-2, 2)), aes((x), xname ="wind")) +
  stat_function(fun = dnorm, args = list(mean = -0.05116279, sd = 0.5725349), aes(colour = "1 hour"))  +
  stat_function(fun=dnorm, args = list(mean = -0.355, sd = 0.6602059),  aes(colour = "4 hour"))  +
  scale_colour_manual("Predictions", values=c("blue","red")) +
  xlab("wind_speed_Error") +
  theme(axis.title.x = element_text(size = rel(1.5)),
        legend.text = element_text(size = rel(1.5)),
        legend.title = element_text(size = rel(1.5)))