Hi Plotly Team,
I may have stumbled across an inconsistency in the api for the bar chart trace. I have gotten used to be able to pass pandas series to trace properties. However assigning the width of a bar chart does not work as expected if a pandas series is passed - the trace is not displayed. A simple example to reproduce the behavior in a Jupyter Notebook is provided below.
import pandas as pd
import plotly.graph_objs as go
df = pd.DataFrame({
'Group': [1, 2, 3],
'Height': [3, 2, 1],
'Width': [0.1, 0.2, 0.3],
})
traces = [
go.Bar(
x=df['Group'],
y=df['Height'],
width=df['Width'].tolist(),
xaxis='x',
),
go.Bar(
x=df['Group'],
y=df['Height'],
width=df['Width'],
xaxis='x2',
),
]
layout = go.Layout(
xaxis={'domain': [0, 0.48]},
xaxis2={'domain': [0.52, 1]},
)
go.FigureWidget(
data=traces,
layout=layout,
)
While the workaround is quite simple, it might be worth considering to make it work with pandas series as well.
Thanks for this great library!
Thanks for the report @roeap, I see what you mean.
Technical notes:
This probably means that plotly.js is not properly handling a typed array passed as the bar.width property, but we should confirm this in a codepen and open a plotly.js issue if so.
@Kully can you port this bug report to a JS Codepen and open an issue in plotly.js (and link back here)?
can you port this bug report to a JS Codepen and open an issue in plotly.js
Here's the JS Issue. I was able to replicate:
https://github.com/plotly/plotly.js/issues/3142
Fixed in Plotly.js in https://github.com/plotly/plotly.js/pull/3169 and released in Plotly.js 1.42.0. This will be included in plotly.py 3.4.0.
Here is the output of the original example on master:

Thanks for taking the time to report this @roeap!