← 返回首页
Allow use of `add_*_selector` methods in `ScatterGraphic` by lkeegan · Pull Request #883 · fastplotlib/fastplotlib · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Allow use of add_*_selector methods in ScatterGraphic#883

Open
lkeegan wants to merge 18 commits into
fastplotlib:mainfrom
lkeegan:scatter_graphic_add_linear_selector
Open

Allow use of add_*_selector methods in ScatterGraphic#883
lkeegan wants to merge 18 commits into
fastplotlib:mainfrom
lkeegan:scatter_graphic_add_linear_selector

Conversation

lkeegan commented Jul 21, 2025

Copy link
Copy Markdown
  • move these existing methods from LineGraphic to common base clase PositionsGraphic
  • regenerate docs

- move these existing methods from `LineGraphic` to common base clase `PositionsGraphic` - regenerate docs

Copy link
Copy Markdown
Member

Hi thanks for your PR!

Supporting selections for scatters will also require implementing the methods to get data from the selections, for example with the rectangle selector:

I'm not sure what a linear or linear region selector means for a scatter, do you have a use case example? I can maybe see the usecase for exploring regression plots.

lkeegan commented Jul 22, 2025

Copy link
Copy Markdown
Author

Hi thanks for your PR!

Supporting selections for scatters will also require implementing the methods to get data from the selections, for example with the rectangle selector:

Thanks for your feedback - and for this very nice library! I'll look into updating these methods.

I'm not sure what a linear or linear region selector means for a scatter, do you have a use case example? I can maybe see the usecase for exploring regression plots.

I guess if one axis in the scatter is time it could make sense to select a time range of data using the linear region selector.
My personal use case is very basic - I just want to be able to select a time on linked plots of time series data, e.g. a line plot of voltage traces and a scatter plot of features extracted from these traces:

plots.mp4

clewis7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Hi @lkeegan

Thanks again for making a PR! I had a few small questions/tweaks. I'm sure @kushalkolar will also want to take a look. I checked out your examples, and they look great!

Comment thread fastplotlib/graphics/_positions_base.py Outdated

# min/max limits
limits = (x_axis_vals[0], x_axis_vals[-1], ymin * 1.5, ymax * 1.5)
limits = (xmin, xmax, ymin, ymax)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Why did you remove the ymin * 1.5 and ymax * 1.5? I think we had that there to allow the selector to go a little bit above and below the graphic.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Ah sorry - I removed it because with positive ymin the limits didn't allow you to select all the data, restored in 75b7d73

Comment on lines +336 to +342
axis_vals_min = np.floor(axis_vals.min()).astype(int)
axis_vals_max = np.floor(axis_vals.max()).astype(int)

bounds_init = axis_vals_min, axis_vals_min + 0.25 * (
axis_vals_max - axis_vals_min
)
limits = axis_vals_min, axis_vals_max

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Can you add code comments here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

sure: c5ec080

clewis7 commented Jul 23, 2025

Copy link
Copy Markdown
Member

@kushalkolar LGTM as long as the examples pass

Copy link
Copy Markdown
Member

I'm going to wait until #837 is merged first since that changes some things with selectors.

lkeegan commented Sep 30, 2025

Copy link
Copy Markdown
Author

@kushalkolar I've updated this PR to include the polygon selector from #837

Copy link
Copy Markdown
Member

Thanks for the update! I'll try this out and merge after #904 so that I don't have to replace the ground truth screenshots multiple times, it will be merged soon! 😄

self._resizable = bool(resizable)

BaseSelector.__init__(self, name=name, parent=parent)
self._move_info = MoveInfo("none", -1, -1, None, None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

@almarklein I'm guessing this was a typo? 😆

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I don't think so, the type of MoveInfo.mode was str. Though in _end_move_mode I did set it to None, so I was not consistent 😆.

So this change looks fine to me, especially with the type now also being mode: str | None.

Comment thread fastplotlib/graphics/scatter.py Outdated
xmin = np.floor(x_axis_vals.min()).astype(int)
xmax = np.ceil(x_axis_vals.max()).astype(int)

# min/max limits include the data + 25% padding in the y-direction

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

might want to pad in both x and y for a scatter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

yes that makes sense

LinearRegionSelector which selects along the x-axis and a vertical selector which moves along the y-axis.
"""

# test_example = false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

make this true, we'd want to have a ground truth screenshot for this since it's a new feature.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

done

Example showing how to use a `PolygonSelector` with a scatter plot.
"""

# test_example = false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

make this true, we'd want to have a ground truth screenshot for this since it's a new feature.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

done

Example showing how to use a `RectangleSelector` with a scatter plot.
"""

# test_example = false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

make this true, we'd want to have a ground truth screenshot for this since it's a new feature.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

done

kushalkolar mentioned this pull request Oct 1, 2025
14 tasks

lkeegan commented Nov 10, 2025

Copy link
Copy Markdown
Author

@kushalkolar thanks for reviewing, I've made the suggested changes and merged the latest changes from the main branch

kushalkolar commented Nov 10, 2025 via email

Copy link
Copy Markdown
Member

kushalkolar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Some comments, sorry for the late response, lots of stuff on our plate lately

Comment thread examples/selection_tools/linear_region_scatter.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/graphics/selectors/_polygon.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/graphics/selectors/_polygon.py Outdated Show resolved Hide resolved
return source.data[s]

if "Scatter" in source.__class__.__name__:
return source.data[ixs]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Is this always valid for an arbitrary scatter? What if we have a blob, like a Gaussian cloud? I think it's only valid for scatters that represent data which are a function of the x or y dim?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I think it's valid for any scatter data - it just returns the subset of data in the selected region:

Comment thread fastplotlib/graphics/selectors/_rectangle.py Outdated Show resolved Hide resolved

self._size_space = SizeSpace(size_space)
super().__init__(*args, **kwargs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Can you update this w.r.t. the current methods

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Done in 6e5b923

lkeegan requested a review from kushalkolar January 30, 2026 10:59
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Footer

© 2026 GitHub, Inc.