Repository navigation
Conversation
ybai08
force-pushed
the
px-scatter-smith
branch
from
October 17, 2026 18:25
e0d9d51 to
f318313
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Closes #4731
Description of change
Adds
px.scatter_smith(data_frame, real=..., imag=..., ...), which buildsgo.Scattersmithtraces the same waypx.scatter_ternarybuildsgo.Scatterternarytraces, with the same arguments for color, symbol, size, text, hover, custom data and animation. To make that work,make_subplotsnow accepts"smith"(and"scattersmith") as a subplot type. Before this change it raisedValueError: Unsupported subplot type: 'smith', and every px figure goes throughmake_subplots.Details:
plotly/_subplots.py: added"smith"to_single_subplot_typesand_subplot_prop_named_subplot. Smith traces use thesubplotproperty, like polar, ternary and map. With that,make_subplotssetslayout.smith/smith2/... domains,add_trace(..., row=, col=)assignssubplot="smith2", andget_subplot/update_traces(row=, col=)resolve smith cells.plotly/express: addedreal/imagto the direct attributes, right afterr/theta, so hover lines come out in the same order as the other coordinate systems (real=%{real}<br>imag=%{imag}). Also added their docstrings, thescatter_smithfunction and the export. The smith layout axes have notitleproperty, so no axis configurator is needed.doc/python/smith-charts.md, anapidocentry, and themake_subplots/get_subplotdocstrings.CHANGELOG.mdentry under Unreleased / Added.I kept the change to
scatter_smith, as the issue asks. Aline_smithcounterpart, likeline_ternary/line_polar, would be a few more lines if you want it here or in a follow-up.Demo
No screenshot attached. The figure was checked through its JSON (trace types, data, subplot, hovertemplate) and not in a browser.
%{real}/%{imag}in the hovertemplate rely on plotly.js copying array attributes into the hover event data and using the trace'srealLabel/imagLabel, the same way%{r}/%{theta}work forscatterpolar.Testing strategy
tests/test_core/test_subplots/test_get_subplot.py::test_get_subplot_smith: a 1x2 grid using"smith"and"scattersmith"gets the right domains,subplotassignment,get_subplotresults andupdate_traces(row=, col=)targeting.tests/test_optional/test_px/test_px_functions.py::test_scatter_smith_pxcompares against an equivalentgo.Scattersmithfigure.test_scatter_smithis parametrized over all dataframe constructors (pandas, pandas nullable/pyarrow, polars, pyarrow) and checks color grouping, data split,markers+textmode and the hovertemplate.Without the source change, all 7 new tests fail: one with
ValueError: Unsupported subplot type: 'smith'and six withAttributeError: module 'plotly.express' has no attribute 'scatter_smith'. With it they pass. Run locally on Python 3.12, macOS:pytest tests/test_core: 456 passed, 1 skippedpytest tests/test_optional/test_px: 1232 passed, 10 skipped, 4 xfailedpytest tests/test_optional/test_subplots tests/test_optional/test_figure_factory: 25 passedpytest tests/test_plotly_utils: 1423 passedruff format --check .: cleanNot run:
tests/test_io(kaleido/Chrome), percy and the docs build.Guidelines