Python Plotly - Align Y Axis for Scatter and Bar

前端 未结 1 2029
闹比i
闹比i 2021-01-02 21:49

I\'m trying to create a plotly graph with a Scatter and Graph elements. It all goes nicely, but one issue - the two Y axis don\'t align around 0.

I have tried playi

相关标签:
1条回答
  • 2021-01-02 22:05

    I have been struggling with this as well. Exact same problem, but I am using R. The way I figured around it was to use the rangemode="tozero" for both the yaxis and yaxis2 layouts.

    I think in your case, it would look like this:

    layout = dict(
    
        title = 'Price/Car',
    
        geo = dict(
            showframe = True,
            showcoastlines = True,
            projection = dict(
                type = 'Mercator'
            )
        ),
    
        yaxis=dict(
            title = 'Price',
            tickprefix = "$",
            overlaying='y2',
            anchor = 'x',
            rangemode='tozero'            
        ),
    
        yaxis2=dict(
            title = 'Car',
            dtick = 1,
            #tickprefix = "",
            side = 'right',
            anchor = 'x',
            rangemode = 'tozero'
    
    
        ),
    
    )
    

    Let me know if that works for you.

    0 讨论(0)
提交回复
热议问题