✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Line chart with Zero in Logarithmic scale

Hi there!

I am using plotly to create line charts with logarithmic y axis.

However, I find the current handling of the 0 value a bit strange because even though the hover recognizes the 0 value, the line chart “ignores it” and shows almost as if there is no data instead of properly connecting the points like in a linear scale chart.

To illustrate my point:
screenshot_139

You can also check the example codepen here

I understand that in the logarithmic scale the 0 value is undefined or invalid, but since they hover just fine, I was wondering if there is way to display the line chart connected to these points?

Thanks in advance!

1 Like

Did you find a way to set the Y-axis limit to zero?

No, that suffers from the same problem I mentioned indeed.

You can see how plotly is handling it inside a bit like “infinity” by checking my codepen and trying different range values, for example :

var layout = {
  yaxis: {
    type: 'log',
    range: [-20, 1],
    rangemode: 'tozero'
  }
};

I think all this would be solved if we could simply alter the log function itself log(x + 1) for example, but I could not find a way to achieve that.