2015-05-05 37 views
0

我正嘗試在R中創建一個格子包。如何修改格子圖形的圖例中的列間距?

我已經寫到現在的代碼如下:

myColours <- brewer.pal(12,"Set3") 
    my.settings <- list(superpose.symbol=list(col=myColours, border="transparent")) 
    png("test_fig.png", width=8.9, height=7, units="cm",res=300) 
    xyplot(sim.values~obs.values, groups=factor(mean.df$month,levels=mixedsort(as.character(unique(mean.df$month)))),data=mean.df, 
      ylim=range(mean.df$obs.values), xlim=range(mean.df$obs.values), 
      xlab=list(label="Obs mean daily rainfall [mm]",cex=0.7), 
      ylab=list(label="Sim mean daily rainfall \n[mm]",cex=0.7), 
      scales=list(cex=0.6), pty="m", pch=20, 
      auto.key=list(space="top", columns=6, text.width=0, cex=0.5, pch=20), 
      par.settings = my.settings, 
      par.strip.text=list(col="white", font=2), 
      panel=function(...){ 
       panel.abline(a=0,b=1) 
       panel.xyplot(...)}) 
    dev.off() 

我得到的是下面的圖像 enter image description here

的問題是在傳說中,其中列有從太遠彼此,我無法適應所有的12個月。任何想法來減少柱間距?

回答

1

between添加到您的auto.key列表中。 例如,

auto.key=list(space="top", columns=6, text.width=0, cex=0.5, pch=20,between=.5), 

或甚至between=0

+0

當然你也可以嘗試3或4列。 – DaveTurek

+0

感謝戴夫,其實是我正在尋找的命令。我嘗試了3或4列,但是圖表有點受到擠壓。 – Corrado