如何在ggplot中更改字体大小和颜色直接标签

时间:2019-08-28 11:12:03

标签: r ggplot2 direct-labels

更改线标签的格式(颜色和大小)时遇到麻烦。有人可以指出我正确的方向吗?

colnames(dfm) = c("date", "portfolio", "return")
p1<- ggplot(dfm) +
  geom_line(aes(x = date, y = return, color = portfolio)) +
  geom_dl(aes(x = date, y = return, label = "portfolio"), method = "last.bumpup", size = 0.01, color = portfolio) +
  geom_hline(yintercept = 100, linetype = "dashed", color = "blue", size = 0.02) +
  theme_classic()
gt1 <- ggplotGrob(p1)
gt1$layout$clip[gt1$layout$name == "panel"] <- "off"
grid.draw(gt1)

current plot

更改size参数似乎并不会改变直接标签的大小。

1 个答案:

答案 0 :(得分:0)

here所述,格式选项位于赋予list参数的method内。