【问题标题】:Changing text size on a ggplot bump plot更改 ggplot 凹凸图上的文本大小
【发布时间】:2011-03-03 14:30:14
【问题描述】:

我对 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())

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    试试这个

      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 映射之外设置大小。

    【讨论】:

    • 谢谢,成功了。我需要花点时间学习 ggplot。
    猜你喜欢
    • 2012-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-29
    • 2021-10-02
    • 1970-01-01
    相关资源
    最近更新 更多