Repository navigation
Fix scatterplot legend with vector-valued s, linewidth or alpha - #4037
Open
twelfthlabor wants to merge 1 commit into
Open
twelfthlabor wants to merge 1 commit into
twelfthlabor wants to merge 1 commit into
Conversation
twelfthlabor
force-pushed
the
fix/scatter-legend-array-kwargs
branch
from
November 16, 2026 15:03
49b6242 to
51cdd3d
Compare
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.
Fixes #3641
scatterplotandrelplotraised whens,linewidthoralphawas given one value per point together with a semantic that draws a legend:Since 0.13.0 the keyword arguments are passed on to the legend artists, and
_scatter_legend_artistgave the whole vector to a singleLine2D.ax.scatteraccepts a vector for these three properties, and the plot itself was drawn correctly, only the legend failed. Without a legend (nohue/size/style, orlegend=False) the same call already worked.A vector can't be shown by one legend entry, so
_scatter_legend_artistnow drops a non-scalars,linewidthoralphaand the handle uses the same default as when the keyword isn't passed. Scalar values are passed on as before.Not changed:
relplotwithcol/rowand a vectorsstill fails, because the vector isn't split by facet. That comes fromFacetGridand isn't related to the legend.Tests: the new
TestScatterPlotter::test_legend_vector_kws(scatterplotandrelplot, for each of the three keywords) fails on master in all 6 cases and passes with the change. The full suite passes withMPLBACKEND=agg(2373 passed) excepttest_utils.py::test_ticklabels_overlap, which also fails for me on master and doesn't use this code.flake8is clean for the changed lines.