← 返回首页
settable `LineStack.separation` by kushalkolar · Pull Request #990 · 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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected Viewed files
Conversations
Failed to load comments. Retry
Loading
Jump to
Jump to file
Failed to load files. Retry
Loading
Diff view
Unified
Split
Hide whitespace
Apply and reload
Show whitespace
Diff view
Unified
Split
Hide whitespace
Apply and reload
26 changes: 20 additions & 6 deletions fastplotlib/graphics/line_collection.py
Show comments View file Edit file Delete file Open in desktop
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
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def __init__(
metadata: Any = None,
metadatas: Sequence[Any] | np.ndarray = None,
isolated_buffer: bool = True,
separation: float = 10.0,
separation: float = 0.0,

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

Default separation needs to be bigger than 0, otherwise it will just plot all of the user's lines on top of each other, which might be confusing/unexpected

If 10 is too big, just do 1.0 or something small

Copy link
Copy Markdown
Member 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

0 stacks them with no gap between the ymax of the previous and ymin of the next. 1 can be too much when the yrange of the data is very small.

Copy link
Copy Markdown
Member 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

So I was thinking 0 would be a good default, just plain stacking

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

So all the lines are on top of each other? Why would someone not just use a LineCollection then?

Maybe the default should be a value based on the data. Similar to vmin/vmax, do a quick calc of the y range or x range depending on the separation axis and use that as the default.

Copy link
Copy Markdown
Member 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

0 means it is placed above the y-max of the previous line, so stacking with no extra spacing

Copy link
Copy Markdown
Member 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

separation_axis: str = "y",
kwargs_lines: list[dict] = None,
**kwargs,
Expand Down Expand Up @@ -610,7 +610,7 @@ def __init__(
metadata for each individual line associated with this collection, this is for the user to manage.
``len(metadata)`` must be same as ``len(data)``

separation: float, default 10
separation: float, default 0.0
space in between each line graphic in the stack

separation_axis: str, default "y"
Expand Down Expand Up @@ -639,16 +639,30 @@ def __init__(
**kwargs,
)

self._sepration_axis = separation_axis
self._separation = separation

self.separation = separation

@property
def separation(self) -> float:
"""distance between each line in the stack, in world space"""
return self._separation

@separation.setter
def separation(self, value: float):
separation = float(value)

axis_zero = 0
for i, line in enumerate(self.graphics):
if separation_axis == "x":
if self._sepration_axis == "x":
line.offset = (axis_zero, *line.offset[1:])

elif separation_axis == "y":
elif self._sepration_axis == "y":
line.offset = (line.offset[0], axis_zero, line.offset[2])

axis_zero = (
axis_zero + line.data.value[:, axes[separation_axis]].max() + separation
axis_zero + line.data.value[:, axes[self._sepration_axis]].max() + separation
)

self.separation = separation
self._separation = value
Loading
Toggle all file notes Toggle all file annotations

Footer

© 2026 GitHub, Inc.