Change background color of R plot

后端 未结 6 1173
北恋
北恋 2020-12-13 17:25

All right, let\'s say I have the following plot.

df = data.frame(date=c(rep(2008:2013, by=1)),
                value=c(303,407,538,696,881,1094))

barplot(df         


        
6条回答
  •  有刺的猬
    2020-12-13 17:56

    One Google search later we've learned that you can set the entire plotting device background color as Owen indicates. If you just want the plotting region altered, you have to do something like what is outlined in that R-Help thread:

    plot(df)
    rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "gray")
    points(df)
    

    The barplot function has an add parameter that you'll likely need to use.

提交回复
热议问题