【问题标题】:How do you center the title in a R Plotly pie chart?如何在 R Plotly 饼图中将标题居中?
【发布时间】:2019-08-05 18:00:21
【问题描述】:

我正在使用 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')

图表的样子:

【问题讨论】:

    标签: r r-plotly


    【解决方案1】:

    看起来类似于这个问题,Left-align chart title in plotly, 在这里稍微修改一下answer,也应该可以解决这个问题。

    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)
      )
    

    来源:

    【讨论】:

      猜你喜欢
      • 2018-03-17
      • 2020-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 2015-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多