plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
15.66k stars 2.51k forks source link

Orientation of colorbar not working in 5.8.0 #3741

Open jdtrebbien opened 2 years ago

jdtrebbien commented 2 years ago

I dont if its best practice, but since I have already submitted a stackoverflow question for this I will just link it here

In short: I updated my plotly [5.8.0] to use the newly implemented orientation of the colorbar to make it horizontally, but it's not changing in any way.

nicolaskruchten commented 2 years ago

Which environment are you running this in? JupyterLab? Dash? Also, if you mouse over the Plotly logo that appears in the top-right, is there a version number for Plotly.js listed there?

jdtrebbien commented 2 years ago

I am using JupyterLab and there is no version number appearing when hovering over the plotly logo.

nicolaskruchten commented 2 years ago

OK, in that case, you're running plotly 5.8.0 but somehow your JupyterLab extension is way behind. Are you running JupyterLab yourself or connecting to a centrally-hosted JupyterHub? And which version of JupyterLab are you running: 2.x or 3.x?

jdtrebbien commented 2 years ago

Ok, I found a way to fix this. I noticed that the colorbar is rotated when saving the plot (using kaleido), which is why I tried changing the renderer in the fig.show() and it worked. The renderer used before was 'plotly_mimetype+notebook' and I changed it to 'png'. It was also working when choosing 'chrome' to open the plot in a new tab.

I am using jupyter lab version 2.2.5.

janosh commented 1 year ago

Same problem here. Plot looks like this in Jupyter:

Screenshot 2023-04-04 at 09 56 48

And like this in the browser after exporting to HTML (with a page loading <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>).

Screenshot 2023-04-04 at 09 56 25

I checked the exported HTML. orientation is as expected:

Screenshot 2023-04-04 at 09 59 38

nicolaskruchten commented 1 year ago

Please note that plotly-latest.min.js is in fact not the latest version. We stopped updating that URL when Plotly.js 2.0 came out to avoid breaking users of that URL, which is now forever pinned to v1.58.5

janosh commented 1 year ago

Ah, that solved the problem! Now using <script src="https://cdn.plot.ly/plotly-2.20.0.min.js"></script>.

Fwiw, I think not updating plotly-latest.min.js is very misleading. People using that expect their code to break on major releases. So I don't see a reason to stop updating it.