如何在ggplot中更改字体大小和颜色直接标签
How to change font size and colour directlabels in ggplot
我在更改线条标签的格式(颜色和大小)时遇到了一些问题。有人能指出我正确的方向吗?
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)
更改大小参数似乎不会改变直接标签的大小。
如前所述 here,格式化选项位于给定 method
参数的 list
中。
我在更改线条标签的格式(颜色和大小)时遇到了一些问题。有人能指出我正确的方向吗?
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)
更改大小参数似乎不会改变直接标签的大小。
如前所述 here,格式化选项位于给定 method
参数的 list
中。