我正在调整ggplot2标签的字体大小以使它们在大格式中更具可读性。除了图例标题外,这种方法非常有效。这是由下面的代码所示:在ggplot2中调整图例标题的位置和字体大小
library(ggplot2)
p <- ggplot(diamonds, aes(carat, price, colour=cut)) + geom_point() +
xlab("Carat") +
ylab("Price") +
opts(legend.position=c(0.85, 0.3)) +
opts(axis.title.x=theme_text(size=16)) +
opts(axis.title.y=theme_text(size=16, angle=90)) +
opts(plot.title=theme_text(size=20)) +
opts(legend.text=theme_text(size=14)) +
opts(legend.title=theme_text(size=14)) +
opts(title="Diamond Prices")
p
重新大小的图例标题在图例框不再正确对齐,而是伸出到左边。对于较长的游戏,效果更糟。我曾尝试为vjust和hjust参数定义自定义值,但没有明显的响应。
有没有办法调整重新调整大小的图例标题的对齐方式?