Skip to content

Make the plotly backends work with Plotly 7 - #1249

Open
Lay-quq wants to merge 1 commit into
SheffieldML:mainfrom
Lay-quq:contrib/SheffieldML__GPy__1243
Open

Lay-quq wants to merge 1 commit into
SheffieldML:mainfrom
Lay-quq:contrib/SheffieldML__GPy__1243

Conversation

@Lay-quq

@Lay-quq Lay-quq commented Oct 25, 2026

Copy link
Copy Markdown

Fixes #1243

With Plotly 7 (the version in poetry.lock) both plotly backends fail:

  • 'plotly_offline': several defaults pass marker sizes as strings (size="5" / size="0"), which Plotly 7 rejects with ValueError: Invalid value of type 'builtins.str' received for the 'size' property of scatter.marker. This breaks plot_inducing, plot_latent / plot_magnification and the error-bar plots.
  • 'plotly' / 'plotly_online': PlotlyPlotsOnline.show_canvas calls plotly.plotly.iplot/plot, which is not part of plotly any more (Chart Studio is a separate package), so it fails with AttributeError: module 'plotly' has no attribute 'plotly'. The backend already imports plotly.subplots, and plotly versions that ship plotly.subplots no longer include plotly.plotly, so this path can't work with any plotly the module supports.

Changes:

  • Use numbers for the marker sizes. These are all the numeric values written as strings in GPy/plotting/plotly_dep/ (all are size; there are no string widths/opacities):
    • defaults.py: inducing_2d, inducing_3d, latent_scatter ("5" -> 5)
    • plot_definitions.py: xerrorbar and yerrorbar, 2D and 3D ("0" -> 0)
  • For the online backend I took the "fail with a message that names plotly_offline / matplotlib" option from the issue: show_canvas now raises a RuntimeError pointing at change_plotting_library('plotly_offline') or 'matplotlib'. This doesn't add Chart Studio as a dependency and doesn't silently turn 'plotly' into the offline backend. Building figures with 'plotly' still works as before; only showing them fails.
  • Tests in test_plotting.py (TestPlotly7) build the figures offline without credentials and skip when plotly is not installed (pytest.importorskip, as in CIP-0009): one per marker-size site and one for the online error message. They fail on main and pass with this change.
  • One line in the Unreleased section of CHANGELOG.md.

Testing (Linux only, plotly 7.1.0 from the lock):

  • New tests: 8 failed on main, 8 passed with this change, on Python 3.11 and 3.12. Reverting any single size change makes its own test fail.
  • poetry run pytest GPy/testing on Python 3.11, base vs. this branch, compared test by test:
    • without plotly (as in CI): 373 passed / 10 skipped -> 373 passed / 18 skipped (the new tests skip), no other change
    • with -E plotting: 374 passed / 9 skipped -> 382 passed / 9 skipped, no other change
  • ruff check and ruff format --check (0.17.1) are clean.

Since CI doesn't install plotly, the new tests are skipped there. Not tested on Windows/macOS or Python 3.13/3.14.

Not changed here: the ErrorX/ErrorY deprecation warnings from plotly.graph_objs, and the places that still point users at the online backend (the 'plotly' example in doc/source/tuto_plotting.rst and the comment in GPy/defaults.cfg). Happy to update those in a follow-up if wanted.

Plotly 7 rejects string marker sizes, so latent, inducing and error-bar
plots raised ValueError under 'plotly_offline'. Use numbers instead.

The 'plotly' / 'plotly_online' library still called plotly.plotly
(Chart Studio), which is no longer part of plotly. Its show_canvas now
raises a RuntimeError that points at 'plotly_offline' or 'matplotlib'.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plotly backend: Chart Studio iplot and string marker sizes break Plotly 7

1 participant