2010-06-14 68 views
2

我对ggplot相当陌生。我使用下面的代码制作了一个bumpplot。我从某人博客的代码 - 我已经失去了链接....在ggplot凹凸图上更改文本大小

我希望能够增加标签的大小(这里的字母在图的左侧和右侧非常小)而不会影响行的宽度(这只会在你运行代码后真正有意义)

我试过更改大小参数,但总是会改变行宽。

任何建议赞赏。

汤姆

require(ggplot2) 
df<-matrix(rnorm(520), 5, 10) #makes a random example 
colnames(df) <- letters[1:10] 
Price.Rank<-t(apply(df, 1, rank)) 
dfm<-melt(Price.Rank) 
names(dfm)<-c("Date","Brand", "value") 
p <- ggplot(dfm, aes(factor(Date), value, 
group = Brand, colour = Brand, label = Brand)) 
p1 <- p + geom_line(aes(size=2.2, alpha=0.7)) + 
    geom_text(data = subset(dfm, Date == 1), aes(x = Date , size =2.2, hjust =  1, vjust=0)) + 
    geom_text(data = subset(dfm, Date == 5), aes(x = Date , size =2.2, hjust = 0, vjust=0))+ 
    theme_bw() + 
    opts(legend.position = "none", panel.border = theme_blank()) 

p1 + theme_bw() + opts(legend.position = "none", panel.border = theme_blank()) 

回答

4

尝试AES映射以外此

geom_text(data=subset(dfm, Date == 1), aes(x=Date), 
      size=12, hjust=1, vjust=0) + 
    geom_text(data=subset(dfm, Date == 5), aes(x=Date), 
      size=20, hjust=0, vjust=0) 

即,设置大小。

+0

谢谢,这工作。我需要花一点时间学习ggplot。 – 2010-06-15 09:20:15