本文介绍了在图表中左对齐图表标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在plot_ly对象(由ggplotly创建)中将图表标题左对齐?
How can I left-align the chart title in a plot_ly object (as created from ggplotly)?
library(ggplot2) library(plotly) p <- ggplot(mtcars, aes(mpg, cyl)) + geom_point() + ggtitle("My Title") + # Not necessary by default: theme(plot.title = element_text(hjust = 0.0)) p ggplotly(p)p的输出(预期的标题对齐):
Output of p (intended title alignment):
ggplotly(p)(不保留标题对齐):
ggplotly(p) (title alignment not preserved):
推荐答案
您可以做到
ggplotly(p) %>% add_annotations( yref="paper", xref="paper", y=1.15, x=0, text="My Title", showarrow=F, font=list(size=17) ) %>% layout(title=FALSE)更多推荐
在图表中左对齐图表标题
发布评论