【问题标题】:Colors won't change on the multiple axis plotly example多轴绘图示例上的颜色不会改变
【发布时间】:2017-02-02 12:46:13
【问题描述】:

我尝试更改“Python 中的多轴”示例中给出的代码的颜色,但颜色没有改变。 https://plot.ly/python/multiple-axes/

不管你改变什么:

titlefont=dict(
    color='rgb(148, 103, 189)'
),
tickfont=dict(
    color='rgb(148, 103, 189)'

到,图表上的颜色保持不变

有什么想法吗?

【问题讨论】:

    标签: python plot ipython plotly


    【解决方案1】:

    颜色应该可以毫无问题地改变,请参见下面的示例(也适用于 RGB 颜色)。

    您确定属性放在legend(和yaxis/2)而不是data

    import plotly.plotly as py
    import plotly.graph_objs as go
    
    trace1 = go.Scatter(
        x=[1, 2, 3],
        y=[40, 50, 60],
        name='yaxis data',
        marker={'color': 'red'}
    )
    trace2 = go.Scatter(
        x=[2, 3, 4],
        y=[4, 5, 6],
        name='yaxis2 data',
        yaxis='y2',
        marker={'color': 'blue'}
    )
    data = [trace1, trace2]
    layout = go.Layout(
        title='Double Y Axis Example',
        yaxis=dict(
            title='yaxis title'
        ),
        yaxis2=dict(
            title='yaxis2 title',
            titlefont=dict(
                color='green'
            ),
            tickfont=dict(
                color='pink'
            ),
            overlaying='y',
            side='right'
        )
    )
    fig = go.Figure(data=data, layout=layout)
    plot_url = py.plot(fig, filename='multiple-axes-double')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多