Skip to content

Waterfall plot doesn't always plot the right axis range #2327

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

Closed
AndreCNF opened this issue Mar 28, 2020 · 6 comments
Closed

Waterfall plot doesn't always plot the right axis range #2327

AndreCNF opened this issue Mar 28, 2020 · 6 comments
Labels
bug something broken

Comments

@AndreCNF
Copy link

AndreCNF commented Mar 28, 2020

Depending on the data values, when setting a base (i.e. initial value), the plot doesn't always adjust the axis range accordingly. For instance, where's a plot working as expected:

import plotly.graph_objs as go
fig = go.Figure()

fig.add_trace(go.Waterfall(
    y = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
    x = [1, 2, 3, -2, -1, 3, -4, 1],
    base = 100,
    orientation='h'
))

fig.show()

image

Now here's what happens when I change a single value in the data (in this case, I changed the third value from 3 to 1):

import plotly.graph_objs as go
fig = go.Figure()

fig.add_trace(go.Waterfall(
    y = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
    x = [1, 2, 1, -2, -1, 3, -4, 1],
    base = 100,
    orientation='h'
))

fig.show()

image

I'm using plotly 4.5.4 and python 3.7.4

Can anyone help me understand what I might be doing wrong or fix this issue?

@emmanuelle
Copy link
Contributor

Thank you @AndreCNF I opened an issue in plotly.js to report the problem. You can use the axis attribute range to set the range explicitly (see https://plotly.com/python/axes/#setting-the-range-of-axes-manually) until it works again. Thanks again!

@emmanuelle emmanuelle added the bug something broken label Mar 28, 2020
@nicolaskruchten
Copy link
Contributor

Changing the third value to 1 causes the seventh to dip below the base, so the axis resets to include zero, basically. Not a great behaviour, admittedly!

@emmanuelle
Copy link
Contributor

In fact it goes to 0 not to negative values so there might be a precision here problem as well?

@AndreCNF
Copy link
Author

Thank you @emmanuelle and @nicolaskruchten for looking into this issue! I see now that it resets the axis whenever it passes the base value (it happens in both directions, either when going from bigger than the base value to smaller than it, or vice versa). Is it possible to correct this behavior? Because this axis reset can make the data less readable (especially if the base value is much bigger than the relative changes) and, in some cases, the value 0 might not even make sense in the current context.

@nicolaskruchten
Copy link
Contributor

I'm sorry I haven't followed up on this issue, but it should be resolved in the most recent version of plotly :)

@AndreCNF
Copy link
Author

AndreCNF commented Jun 1, 2020

@nicolaskruchten Yes, it's resolved. That's why I closed this issue. Thanks for the help! 🙂

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

3 participants