2012-09-29 25 views
3

我正在使用ggplot绘制一些数据。它工作正常,但我想控制绘制区域的形状,并删除灰色背景。R减小图表大小并从ggplot中删除灰色背景

这是我现在使用的代码:

ggplot(data.melted, aes(x = Year, y = value, colour = variable)) + 
    geom_line() + 
    scale_x_continuous("Year") + 
    scale_y_continuous("Fraction of papers") + 
    scale_colour_discrete("Topics") 

,这是它产生的输出:enter image description here

回答

6
ggplot(data.melted, aes(x = Year, y = value, colour = variable)) + 
    geom_line() + 
    scale_x_continuous("Year") + 
    scale_y_continuous("Fraction of papers") + 
    scale_colour_discrete("Topics") + theme(panel.background = element_blank()) 

要保存的情节时指定的尺寸。有关其他选项,请参见?ggsave

ggsave(p1, file = "plot.png", width = 5, height = 5)