Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬 Access the recorded webinar.

How to set different x and y axis for each subplot?

I have a table with products and categories. I want to create subplots for each category.

import plotly.express as px
import pandas as pd

data = {'Category':["Toys","Toys","Toys","Toys","Food","Food","Food","Food","Food","Food","Food","Food","Furniture","Furniture","Furniture"], 
df = pd.DataFrame(data)
fig = px.bar(df, x="Product", y="QTY", barmode="group",facet_col="Category")

But I get the same x and y axes in the charts. How can I set for each plot a coordinate axis for its data? That is, the x-axis will have only products that belong to the same category. The y-axis maximum value will be equal to the maximum quantity in each category…

Hey there,

Just add the following rows:

fig.update_xaxes(matches=None, showticklabels=True)
fig.update_yaxes(matches=None, showticklabels=True)