Description
Because microsoft/vscode-notebook-renderers#199 is unmerged, users of Plotly.py using the VSCode notebooks cannot access the latest Plotly.js/Plotly.py features and no discernible error message is provided. This leads to confusion, because users are working with the latest version of Plotly.py and their charts don't work properly.
This has caused issues for adoption of new features like MapLibre and subtitles in charts, and may others. See e.g.:
- Subtitle does not render following example from docs #4715
- Scattermap Class doesn't render #4775
- Plotly 5.23.0, Hover on Subplots Only Work on one subplot #4701
- zorder doesn't work on version 5.21.0 #4583
- multiple Legends not working in VS code #4560
- Shape labels missing/not showing #4475
- Sankey align plotly v5.19.0, initial issue #6800 #4528
- Multiple legends does not work with subplots #4264
- Label aliases does not work at MacOS #4173
- scattermode="group" not working #4094
Developers can workaround this by adding to their notebook:
import plotly.io as pio
pio.renderers.default = "notebook_connected"
While this is trivial to change, it's undiscoverable and non-intuitive. If you have the latest version of Plotly.py installed, you should be able to use the latest features in any Python environment!
Regardless of whether microsoft/vscode-notebook-renderers#199 is merged, this dependency means VSCode Notebook users will always lag behind Plotly.py releases as we wait for VSCode to adopt and release their own updates, which means VSCode users would never have day-of updates without a workaround 🙁
Is it possible to detect that we're in a VSCode Notebook environment and automatically set the correct renderer to avoid this dependency on a VSCode update?