更改 ggplot 凹凸图上的文本大小
我对 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())
I'm fairly new to ggplot. I have made a bumpplot using code posted below. I got the code from someones blog - i've lost the link....
I want to be able to increase the size of the lables (here letters which care very small on the left and right of the plot) without affecting the width of the lines (this will only really make sense after you have run the code)
I have tried changing the size paramater but that always alter the line width as well.
Any suggestion appreciated.
Tom
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())
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个
,即将大小设置在 aes 映射之外。
Try this
i.e., set the size outside of the aes mapping.