Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions fastplotlib/graphics/line_collection.py
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
Member

Choose a reason for hiding this comment

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

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
Member Author

Choose a reason for hiding this comment

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

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
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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.

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