problem with log_x not working in histogram
See original GitHub issueHi,
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)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How can I plot a histogram with a logarithmic X-axis?
The ability to directly plot a histogram with a logarithmic x-axis is not available in MATLAB. To work around this issue, use the...
Read more >Log x-axis for histogram - matplotlib - Stack Overflow
I'm trying to plot a histogram with a logarithmic x axis. ... argument as it normalizes using distances and not logarithmic distances.
Read more >Draw histogram with logarithmic x-axis with custom range
The problem is that your histogram has only 4 bins and SetRange and SetRangeUser ultimately are also bin wise. They call SetRange.
Read more >Draw Histogram with Logarithmic Scale in R (3 Examples)
How to change the x-axis of a graph to log scale in the R programming language.
Read more >Histograms on Log Axis - Graphically Speaking - SAS Blogs
Often there are questions from users on creating histogram using a Log X axis. One such question came up this weekend, where a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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.