Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistency in (bar) chart api - width does not accept pandas series #1231

Closed
roeap opened this issue Oct 19, 2018 · 4 comments
Closed

inconsistency in (bar) chart api - width does not accept pandas series #1231

roeap opened this issue Oct 19, 2018 · 4 comments
Labels
bug something broken
Milestone

Comments

@roeap
Copy link

roeap commented Oct 19, 2018

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!

@jonmmease
Copy link
Contributor

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.

@jonmmease jonmmease added the bug something broken label Oct 20, 2018
@bpostlethwaite
Copy link
Member

@Kully can you port this bug report to a JS Codepen and open an issue in plotly.js (and link back here)?

@Kully
Copy link
Contributor

Kully commented Oct 23, 2018

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:
plotly/plotly.js#3142

@jonmmease jonmmease added this to the v3.4.0 milestone Oct 30, 2018
@jonmmease
Copy link
Contributor

Fixed in Plotly.js in plotly/plotly.js#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:
newplot 65

Thanks for taking the time to report this @roeap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

4 participants