Dual Axis Chart

Hi,

I am trying to make dual axis chart in streamlit but ended up in error. can anyone guide me how to make two different y axis on both vertical sides of chart with x axis.

e71e0726-1cd3-401a-983a-8be362598600

If possible, please share the source code

Hi,

Use matplotlibโ€™s ax.twinx() function. For example:

fig, ax = plt.subplots(1, figsize=(15,5))
ax_2 = ax.twinx()

# configure ax and ax_2 as you wish
# ...

# Set X label 
ax.set_xlabel('X Label')

# Set twin Y labels 
ax.set_ylabel('Y Label' 1)
ax_2.set_ylabel('Y Label 2')

# Plot the figure
st.pyplot(fig)

thanks, its working

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.