I am trying to make 3x4 subplots where 3rd row had secondary axis, but, for some reasons, data that i added on that axes is not showing.
The code is like:
import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import plotly
def test():
fig = make_subplots(rows=3, cols=4, start_cell="top-left", shared_xaxes=True, shared_yaxes=True,
subplot_titles=('1st', '2nd', '3rd', '4th', '', '', '', '', '', '', '', ''))
fig.update_xaxes(showline=True, linewidth=2, linecolor='gray', ticks="outside", tickcolor='gray')
fig.update_yaxes(showline=True, linewidth=2, linecolor='gray', ticks="outside", tickcolor='gray')
fig.update_layout(
paper_bgcolor='rgba(255,255,255,1.0)',
plot_bgcolor='rgba(255,255,255,1.0)'
)
for k in range(13, 17):
fig.update_layout({'yaxis{}'.format(k): dict(anchor='x' + str(k-4),
overlaying='y'+str(k-4),
side='right',
showline=True,
linewidth=2,
linecolor='gray',
ticks="outside",
tickcolor='gray',
matches='y13'
)
})
x_list = np.arange(0,10, 1)
for i in range(4):
trace1 = dict(
x=x_list,
y=np.random.rand(10),
line=dict(
color='#39B850'
),
name='1 - ' + str(i)
)
trace2 = dict(
x=x_list,
y=np.random.rand(10),
name='2 - ' + str(i),
line=dict(
color='#4543B9'
)
)
trace3 = dict(
x=x_list,
y=np.random.rand(10),
name='3 - ' + str(i),
line=dict(
color='#616BD9',
dash='dot'
)
)
trace4 = dict(
x=x_list,
y=np.random.rand(10),
name='4 - ' + str(i),
line=dict(
color='#9F36AE'
)
)
trace5 = dict(
x=x_list,
y=np.random.rand(10)*3,
yaxis='y' + str(i+13),
name='5 - ' + str(i),
line=dict(
color='#C76AD4',
dash='dot'
)
)
fig.add_trace(trace1, row=1, col=i+1)
fig.add_trace(trace2, row=2, col=i+1)
fig.add_trace(trace3, row=2, col=i+1)
fig.add_trace(trace4, row=3, col=i+1)
fig.add_trace(trace5)
fig.show()
Traces β5 - 0β, β¦ , β5 - 3β were added to their axes and showed in the legend, but they arenβt visible on the subplots. Why and how do i fix it?