Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

How can I plot a secondary y axis in python notebook?

Thanks for the help in advance,

was having trouble plotting to a second y-axis in plotly in jupyer notebooks. Code is below that produces a line chart. Wanted a second Y axis displaying minutes onb the second axis vs a % on the left. Cant figure that out

from plotly import version
import cufflinks as cf
from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot
init_notebook_mode(connected=True)
cf.go_offline()

Add data

Weeks = Grouped_df[‘week_starting’]

Soft_Reject_Rate = Grouped_df[‘Soft_Reject_Rate’]
Hard_Reject_Rate = Grouped_df[‘Hard_Reject_Rate’]
Total_Reject_Rate = Grouped_df[‘Total_Reject_Rate’]

Create and style traces

trace0 = go.Scatter(
x = Weeks,
y = Soft_Reject_Rate,
name = ‘Soft_Reject_Rate’,
line = dict(
color = (‘rgb(205, 12, 24)’),
width = 4)
)
trace1 = go.Scatter(
x = Weeks,
y = Hard_Reject_Rate,
name = ‘Hard_Reject_Rate’,
line = dict(
color = (‘rgb(22, 96, 167)’),
width = 4,)
)
trace2 = go.Scatter(
x = Weeks,
y = Total_Reject_Rate,
name = ‘Total_Reject_Rate’,
line = dict(
color = (‘rgb(205, 12, 24)’),
width = 4,
dash = ‘dash’) # dash options include ‘dash’, ‘dot’, and ‘dashdot’

)
data = [trace0, trace1, trace2]

Edit the layout

layout = dict(title = ‘Reject Rates - Spring through YTD’,
xaxis = dict(title = ‘Weekly Progession’),
yaxis = dict(title = ‘%’),
)

fig = dict(data=data, layout=layout)

iplot(fig)

@ssharma87 Here is an example on how to define left and right yaxes: https://plot.ly/~empet/14349.