2013-04-08 46 views
0

我有看起来像this的数据。如何放大面板以包含长传说标签

我当前的代码在这里

library(ggplot2) 
library(RColorBrewer) 
pal <- c(brewer.pal(8,"Dark2"),brewer.pal(12,"Paired")); 
dat<-read.table("http://dpaste.com/1051194/plain/",header=TRUE) 
dat.sub <- data.frame(dat$Function,dat$Freq) 
ggplot(dat.sub,aes(dat.Freq,color=dat.Function),shape=dat.Function)+ stat_density(geom="path",position="identity",size=0.5) 

产生类似下图: enter image description here

注意图例文本的长度引起的主要情节被挤压。 处理这个问题的最好方法是什么,这样数字显得正常 ,图例也显示了完整性?

+0

更宽的设备 – James 2013-04-08 14:30:12

+0

你如何做到这一点的情节? – neversaint 2013-04-08 14:31:17

+1

如果以交互方式使用窗口,则可以展开该窗口,或者使用'ggsave'的'width'参数设置设备的大小。 – James 2013-04-08 14:33:12

回答

5

一种可能性是将图例置于图下,然后将标签排列在两列中。

ggplot(dat.sub,aes(dat.Freq,color=dat.Function),shape=dat.Function)+ 
    stat_density(geom="path",position="identity",size=0.5)+ 
    theme(legend.position="bottom",legend.direction="vertical")+ 
    guides(color=guide_legend(ncol=2)) 

enter image description here