增加 plot_ly() 创建的气泡的大小 where mode = "markers"

Posted

技术标签:

【中文标题】增加 plot_ly() 创建的气泡的大小 where mode = "markers"【英文标题】:increase the size of the bubbles created by the plot_ly() where mode = "markers" 【发布时间】:2016-10-24 06:41:54 【问题描述】:
plot_ly(ProdSummary, x = logMetricRevenue2016, y = MarginPercent2016,
        mode = "markers" , axes=F , size = (Quantity2016), color=Brand, text=paste("P_Code",product_code))

生成的气泡图显示了小气泡,我可以这样做size=Quantity2016*100,但这不会增加图表上气泡的大小。都是相对的。

【问题讨论】:

试试marker = list(size = Quantity2016*100)注意,您还需要添加一些数据并将您的问题格式化为一个最小的工作示例。就目前而言,它很可能被标记为删除,因为它不可重现。请阅读 this、this 和 read the help pages 以更好地了解如何在 SO 上提问。 【参考方案1】:

尝试在marker 下添加sizerefsizemode。特别是玩弄sizeref的不同值:

trace = go.Scatter(x=x,
                   y=y, 
                   mode='markers',
                   marker=dict(
                               size=[abs(i) for i in Quantity2016],
                               sizeref=0.1,
                               sizemode='area'
                              )
                   )

请注意, size 在你的 Quantity2016 列表中的负值会使这些点消失(或者我想被绘制为大小 0 ),所以请注意这一点。

【讨论】:

以上是关于增加 plot_ly() 创建的气泡的大小 where mode = "markers"的主要内容,如果未能解决你的问题,请参考以下文章