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

problem with log_x not working in histogram #2899

Open
pjadzinsky opened this issue Nov 12, 2020 · 9 comments
Open

problem with log_x not working in histogram #2899

pjadzinsky opened this issue Nov 12, 2020 · 9 comments

Comments

@pjadzinsky
Copy link

Hi,

I'm new to plotly and it seems to me that following behavior is a bug.

Can someone please verify it?

Thanks for a great library.

from plotly import express as px

# this works just fine
px.histogram(np.random.randint(0, 8, 100), log_y=True, log_x=False)

# but this "works" but it produces an empty plot, no errors are raised
px.histogram(np.random.randint(0, 8, 100), log_y=False, log_x=True)
@nicolaskruchten
Copy link
Member

It's not a bug, we just have not yet implemented histograms on log scales :)

@pjadzinsky
Copy link
Author

Thanks for the prompt reply, but the strange thing is that it works on log_y.
Would also be useful if it was throwing a "NonImplementedError"

@nicolaskruchten
Copy link
Member

That's a good idea! Should be fairly straightforward to implement in PX since the recent changes to explicitize orientation if you're up to submit a PR!

@pjadzinsky
Copy link
Author

Sure I can do that but I have no idea where to look for things. I have not looked at this repo in any way

@nicolaskruchten
Copy link
Member

It'll be in a file called _core.py (sorry, replying from my phone, can't find full path just now ;)

@grisaitis
Copy link
Contributor

@nicolaskruchten have log scale histograms been implemented anywhere yet? if not i can add look into adding this NotImplementedError.

@nicoszerman
Copy link

I'm having the same problem, would be awesome to have this implemented or make it throw NotImplementedError. Thank you!

@acssantos
Copy link

For my use case, I made an implementation using numpy to build the histogram and plot it with a Bar plot customizing the ticks and hover data.

https://gist.github.com/acssantos/3108539189e60e4b059130259d21f5a9

Hope it can help circumvent the problem.

@nicolaskruchten
Copy link
Member

nicolaskruchten commented May 31, 2022

So there is in fact a bug here, sorry to have misdiagnosed it earlier. Setting log_x=True causes the x-axis to become logarithmic, and when a bin edge is 0, the bars disappears. I've filed a bug in the upstream Plotly.js repo to fix this.

Note that setting log_x=True does not cause the bin edge calculation to change, so your bins will appear to be of different widths, as they do right now if you don't have a bin edge at 0.

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

No branches or pull requests

5 participants