Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Bar Chart + Subplot

Hi guys I have some issues configuring my subplot of barcharts correctly, the documentation isn’t very helpful either.

My code:

from plotly.subplots import make_subplots
import plotly.graph_objects as go
from datatable import dt, f, by

df = dt.Frame(row=[1, 1, 2, 2, 1, 2], col=[3, 2, 2, 1, 1, 3])

subplot_bar = make_subplots(rows=2, cols=3, specs=[[{"type": "bar"}] * 3] * 2, subplot_titles=['a', 'b', 'c', 'd', 'e', 'f'])

for x in range(df.nrows):
    dfplot = dt.Frame(a=['A', 'B', 'C', 'D'], b=[x + 1] * 4).to_pandas()
    subplot_bar.add_trace(go.Bar(x=dfplot['a'], y=dfplot['b'], marker_color='rgb(99,110,251)'), row=df[x, 'row'], col=df[x, 'col'])




  1. y-axis label
  2. y-axis max value should be the same for each plot
  3. change background color to white

Any suggestion are highly appreciated!

@HansPeter123 You can set yaxes matches to None as follows


You can see the documentation here:

Hope this help!

Hi! @HansPeter123

To update the background color of your plots, update your subplot figure with:
subplot_bar.update_layout(showlegend=False, plot_bgcolor='white')

To label individual subplot y axes, update the axes with code like the below:

subplot_bar.update_yaxes(title_text="yaxis 1 title", row=1, col=1)

Cheers! Taylor

Hi @thalerobert and @alooksha. Thank you very much!

@HansPeter123 sure thing. good luck on your project!