我对ggplot很新。我使用下面发布的代码制作了一个bumpplot。我从某人博客那里得到了代码 - 我丢失了链接......
我希望能够增加标签的大小(这里字母在图的左侧和右侧非常小)而不会影响线条的宽度(这只有在你运行之后才有意义)代码)
我尝试更改尺寸参数,但也总是改变线宽。
任何建议都表示赞赏。
汤姆
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())
答案 0 :(得分:4)
试试这个
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)
即,将大小设置在aes映射之外。