繁体   English   中英

如何在R Plotly饼图中将标题居中?

[英]How do you center the title in a R Plotly pie chart?

我正在使用R与Plotly一起工作,无法将标题居中放在饼图上。 标题看起来有点像右边。 有没有办法做到这一点,并将其向左或靠近饼图的中间移动?

这是代码:

label_names = c('Feeds','All Others') 
numbers = c(first_reported, not_first_reported)

pie_colors <- c('rgba(173,216,230,1)', 'rgba(0,0,139,1)')
plot_ly(labels=label_names, values=numbers, type='pie', 
        insidetextfont = list(color = '#FFFFFF'),
        marker = list(colors=pie_colors)) %>%
  layout(title = 'Portion of Feeds')

图表如下所示:

在此处输入图片说明

看起来与此问题类似, 在图中将图表标题左对齐 ,只需在此处稍微修改一下答案 ,也应该对此起作用。

plot_ly(labels=label_names, values=numbers, type='pie', 
        insidetextfont = list(color = '#FFFFFF'),
        marker = list(colors=pie_colors)) %>%
  add_annotations(
    y=1.05, 
    x=0.5, 
    text="Portion of Feeds", 
    showarrow=F,
    font=list(size=15)
  )

资源:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM