Python Forum
Not able to update y2 axis scale in plotly - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Not able to update y2 axis scale in plotly (/thread-24012.html)



Not able to update y2 axis scale in plotly - ankitawadhwa - Jan-27-2020

Hi,
Could you please help me updating the scale for y_2 axis
fig.update_yaxes(tickvals=[0.0,0.5,0.75,1.0,1.25,1.5,1.75,1.8,1.9,2.0,2.5,3.0,4.0,4.5,5.0,5.25,5.5,6.0],secondary_y=True)
This line isn't working

Code :
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(go.Bar(
x=final['Build_date'],
y=final['First Year Trips'],
name='First Year Trips',
marker_color='Blue'
))
fig.add_trace(go.Bar(
x=final['Build_date'],
y=final['Build_Count'],
name='Build_Count',
marker_color='lightsalmon'
))
fig.add_trace(go.Bar(
x=final['Build_date'],
y=final['ZeroTripChassis'],
name='ZeroTripChassis',
marker_color='yellow'
))

fig.add_trace(
go.Scatter(x=final['Build_date'], y=final['Rolling_Avg'], name="12M Rolling Average of First Year Trips/Truck."),
secondary_y=True,
)

fig.update_yaxes(tickvals=[0.0,0.5,0.75,1.0,1.25,1.5,1.75,1.8,1.9,2.0,2.5,3.0,4.0,4.5,5.0,5.25,5.5,6.0],secondary_y=True)

fig.update_layout(barmode='group', xaxis_tickangle=-45)
fig.update_yaxes(title_text="Count", secondary_y=False)
fig.update_yaxes(title_text="Trips", secondary_y=True)
fig.show()