I am constructing a group of histogram plots with the following code.
fig = make_subplots(rows=3, cols=3, subplot_titles=(list(dfs.keys())))
for i, df in enumerate(dfs.values()):
row, col = int(i / 3) + 1, (i % 3 ) + 1
fig.add_trace(go.Histogram(x=df.perf_time, xbins={"start":0, "end":600}, histnorm='probability'), row=row, col=col)
fig.update_layout(height=750, width=1050, showlegend=False, title_text="Performance Times")
For reasons I can’t explain, the resulting figure does not obey the xbins limits I set. Instead, each histogram has a default x-axis range. Any ideas on how to make this work as intend?
import numpy as np
import pandas as pd
from plotly.subplots import make_subplots
import plotly.graph_objects as go
dfs = {str(i): pd.DataFrame({"x": np.random.normal(i, 1, size=100)}) for i in range(9)}
fig = make_subplots(rows=3, cols=3, subplot_titles=(list(dfs.keys())))
for i, df in enumerate(dfs.values()):
row, col = int(i / 3) + 1, (i % 3) + 1
fig.add_trace(go.Histogram(x=df.x, xbins={"start":-4, "end":14}, histnorm='probability'), row=row, col=col)
Below is the resulting figure. Notice that the xbins limits aren’t obeyed.
Thanks for your help AIMPED! After some more testing based on your feedback, I’ve realized that my test case for xbins wasn’t as clear as it should have been. The case below demonstrates more clearly that xbins is working properly. My original confusion was that I didn’t expect the x-axis to “zoom in” on the data, I thought it was representing the limits of the bins.
import numpy as np
import pandas as pd
from plotly.subplots import make_subplots
import plotly.graph_objects as go
dfs = {str(i): pd.DataFrame({"x": np.random.normal(i, 1, size=100)}) for i in range(9)}
fig = make_subplots(rows=3, cols=3, subplot_titles=(list(dfs.keys())))
for i, df in enumerate(dfs.values()):
row, col = int(i / 3) + 1, (i % 3) + 1
fig.add_trace(go.Histogram(x=df.x, xbins={"start":0, "end":8}, histnorm='probability'), row=row, col=col)