Adding title to plotly legend in R

I'd like to add a legend-title to my plotly graph (made in R). This doesn't seem possible in any straightforward fashion.

If nothing else works, I might add an annotation to the graph right above where the legend entries are shown. That said, I'm not sure where to anchor said notation.

I'm not sure how to proceed. Thanks.


您可以通过为两者指定相同的y坐标并使用yanchor将每个元素放置在正确的一侧来将图例标题固定在图例上:

plot_ly( ... ) %>%
  add_annotations( text="MyTitle", xref="paper", yref="paper",
                  x=1.02, xanchor="left",
                  y=0.8, yanchor="bottom",    # Same y as legend below
                  legendtitle=TRUE, showarrow=FALSE ) %>%
  layout( legend=list(y=0.8, yanchor="top") )
链接地址: http://www.djcxy.com/p/31628.html

上一篇: 贝宝ssl握手faliure

下一篇: 在R中为剧情图例添加标题