question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem with log_x not working in histogram

See original GitHub issue

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)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, 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.

0reactions
acssantoscommented, May 24, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found