Skip to content

log_x not working in histogram #2899

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

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

log_x not working in histogram #2899

pjadzinsky opened this issue Nov 12, 2020 · 12 comments
Labels
bug something broken P3 backlog

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
Contributor

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
Contributor

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
Contributor

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
Contributor

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.

@gvwilson gvwilson self-assigned this Jul 4, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 backlog label Aug 12, 2024
@gvwilson gvwilson changed the title problem with log_x not working in histogram log_x not working in histogram Aug 12, 2024
@gvwilson gvwilson added the bug something broken label Aug 12, 2024
@Msx1998
Copy link

Msx1998 commented Nov 22, 2024

Any progress?

@gvwilson
Copy link
Contributor

Hi @Msx1998 - this one isn't currently on our roadmap, but we'd be happy to review a pull request from the community. Thanks - @gvwilson

@zndr27
Copy link

zndr27 commented Mar 24, 2025

Is this still not implemented? I'm having the same issue.

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

No branches or pull requests

8 participants