Skip to content

Draw connector lines below their points instead of on top#42

Open
cduvallet wants to merge 2 commits into
ckjellson:mainfrom
cduvallet:fix/line-below-point
Open

Draw connector lines below their points instead of on top#42
cduvallet wants to merge 2 commits into
ckjellson:mainfrom
cduvallet:fix/line-below-point

Conversation

@cduvallet

@cduvallet cduvallet commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Connector lines drawn by allocate() went to the
center of each point, using matplotlib's default zorder (2), which
is above the default zorder for scatter/patch collections (1). This
made the line color show through the point marker instead of
tucking behind it.

This PR adds a linezorder param to allocate(). It defaults to None,
which resolves to a value below the point's zorder (further lowered
to stay below scatter_plot's own zorder if provided) so the point
visually caps the line where it meets it. An explicit linezorder
(or plot_kwargs={"zorder": ...}) overrides this.

Also adds an example to the demo notebook.

Before / after

Before:
before

After:
after

Test plan

  • Verified visually in an isolated environment that lines render
    behind points by default, both with and without scatter_plot
    passed.
  • Verified explicit linezorder and plot_kwargs={"zorder": ...}
    overrides are respected even when scatter_plot is provided.
  • Added a demo section to demo.ipynb showing default vs.
    overridden linezorder behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ckjellson

Copy link
Copy Markdown
Owner

Thank you, good catch!

I like changing the default value, but I feel like adding more parameters is not necessary since one can change the setting via plot_kwargs (linewidth is probably also redundant...). Suggestions:

  1. Remove the new parameter, but set zorder in line_kwargs to your default value unless the option has been specified in plot_kwargs.
  2. Remove images in ./images from the commit.
  3. Restore changes to demo.ipynb (I don't want it to contain too much stuff)

What do you think?

Fold the below-point zorder default directly into line_kwargs instead
of exposing a separate linezorder parameter — plot_kwargs remains the
one escape hatch for overriding it. Also reverts demo.ipynb and drops
the added images per review feedback.
@cduvallet

cduvallet commented Jul 24, 2026

Copy link
Copy Markdown
Author

All great points, and implemented! I also updated the plot_kwargs docstring to (1) mention zorder and (2) make it explicit that plot_kwargs overrides provided params (e.g. linewidth).

As a user, I appreciate having linewidth as an easily accessible parameter, so while it is technically redundant I would keep it in :)

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.

2 participants