Hi,
I would like to add the second ‘x’ axis (line, ticks and title) to a subplot horizontal bar chart to have the same axis on both sides. However, when I use a bar chart with horizontal orientation, I cannot use ‘secondary_x’.
Is there any trick to apply here? Thanks.
O.
import plotly.graph_objects as go
from plotly.subplots import make_subplots
fig = make_subplots(
rows=3, cols=3,
column_widths=[0.25,0.5,0.25],
row_width=[0.2,0.6,0.2],
horizontal_spacing=0.01,
vertical_spacing=0.01,
subplot_titles=('','Vertical plots','','','','','','','') ,
print_grid=True, # layout tuning
specs=
[
[{}, {},{}],
[{}, {"secondary_y": True},{}], ## no secondary_x feature
[{}, {},{}],
]
)
bars = [1,2,3,4,5,6,7,8]
fig_bars = go.Bar(y=bars, x=bars, orientation='h', text=bars)
fig.add_trace(fig_bars, row=2, col=2)
fig.update_yaxes(tick0=0, dtick=1, showline=True, linewidth=1, linecolor='#696969', ticks="outside", tickwidth=0.5, tickcolor='#696969', range=[0,10], ticklen=2, row=2, col=2)
fig.update_xaxes(title='Size (mm)', gridcolor='white', range=[0,11], ticks="outside", showline=True, linewidth=1, linecolor='#696969', row=2, col=2)
fig.update_layout(height=600, width=200, paper_bgcolor='rgba(0,0,0,0.0)', plot_bgcolor='rgba(248,248,248,0.9)', margin=dict(l=20, r=20, t=20, b=20))
fig.show()