✊🏿 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!

Discontinuity when plotting continuous days with and without a leap year

Hi- we have a dashboard that uses plotly.js to compare year-over-year time-based data. So, we’ll plot one trace for every day this year and another trace for every day last year, using the ‘%m/%d’ x tick format to make them appear on the same time scale.

This has worked fine until this recent leap day occurred. Now, there is a discontinuity in the 2020 data and the 2/29 point is rendered at the end of the x axis instead of its proper place. Here’s an example made with a codepen

https://codepen.io/ajselvig/pen/yLNzJjY

It’s not immediately obvious to me how to get around this. Has anyone dealt with something like this before?

Thanks!

It does appear that reversing the order of the traces fixes the issue (I guess it uses the first trace to compute the x axis values?). It’s not a great solution, but it’ll work if anyone else comes across this.