Skip to content

Commit 45f1dd2

Browse files
author
Caitlin Lewis
committed
docs updates
1 parent 6df039f commit 45f1dd2

5 files changed

Lines changed: 41 additions & 48 deletions

File tree

fastplotlib/graphics/_base.py

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,23 @@ def __init__(
6060

6161
@property
6262
def world_object(self) -> WorldObject:
63-
"""Return the underlying pygfx WorldObject."""
63+
"""Associated pygfx WorldObject."""
6464
return self._world_object
6565

6666
@property
6767
def position(self) -> Vector3:
68-
"""The position of the graphic."""
68+
"""The position of the graphic. You can access or change
69+
using position.x, position.y, etc."""
6970
return self.world_object.position
7071

7172
@property
7273
def visible(self) -> bool:
73-
"""Returns the visibility of the pygfx WorldObject."""
74+
"""Access or change the visibility."""
7475
return self.world_object.visible
7576

7677
@visible.setter
77-
def visible(self, v):
78-
"""Toggle the visibility of this Graphic."""
78+
def visible(self, v) -> bool:
79+
"""Access or change the visibility."""
7980
self.world_object.visible = v
8081

8182
@property
@@ -156,36 +157,6 @@ def link(
156157
-------
157158
None
158159
159-
Examples
160-
--------
161-
.. code-block:: python
162-
163-
from fastplotlib import Plot
164-
import numpy as np
165-
# generate data for cosine and sine wave
166-
xs = np.linspace(-10, 10, 100)
167-
# sine wave
168-
ys = np.sin(xs)
169-
sine = np.dstack([xs, ys])[0]
170-
# cosine wave
171-
ys = np.cos(xs) + 5
172-
cosine = np.dstack([xs, ys])[0]
173-
# instantiate a plot
174-
plot = Plot()
175-
# create graphics and add them to the plot
176-
sine_graphic = plot.add_line(data=sine, thickness=5, colors="magenta")
177-
cosine_graphic = plot.add_line(data=cosine, thickness=12, cmap="autumn")
178-
# show plot
179-
plot.show()
180-
# link color change of sine graphic to cosine graphic
181-
sine_graphic.link(event_type="colors",
182-
target=cosine_graphic,
183-
feature="colors",
184-
new_data="w",
185-
bidirectional=False)
186-
# changing colors of sine graphic at indexes 1-3 to red
187-
# changes cosine graphic to white
188-
sine_graphic.colors[1:3] = "r"
189160
"""
190161
if event_type in PYGFX_EVENTS:
191162
self.world_object.add_event_handler(self.event_handler, event_type)
@@ -498,7 +469,7 @@ def remove_event_handler(self, handler: callable):
498469
fi.remove_event_handler(handler)
499470

500471
def block_events(self, b: bool):
501-
"""Prevents event handling from occurring."""
472+
"""Blocks event handling from occurring."""
502473
for fi in self._feature_instances:
503474
fi.block_events(b)
504475

fastplotlib/graphics/image.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ def __init__(
7777

7878
@property
7979
def vmin(self) -> float:
80-
"""Returns the minimum contrast limit."""
80+
"""Minimum contrast limit."""
8181
return self.world_object.material.clim[0]
8282

8383
@vmin.setter
8484
def vmin(self, value: float):
85-
"""Sets the minimum contrast limit."""
85+
"""Minimum contrast limit."""
8686
self.world_object.material.clim = (
8787
value,
8888
self.world_object.material.clim[1]
8989
)
9090

9191
@property
9292
def vmax(self) -> float:
93-
"""Returns the maximum contrast limit."""
93+
"""Maximum contrast limit."""
9494
return self.world_object.material.clim[1]
9595

9696
@vmax.setter
9797
def vmax(self, value: float):
98-
"""Sets the maximum contrast limit."""
98+
"""Maximum contrast limit."""
9999
self.world_object.material.clim = (
100100
self.world_object.material.clim[0],
101101
value

fastplotlib/graphics/line_collection.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ def __init__(
7878
ys = np.sin(xs)
7979
sine = np.dstack([xs, ys])[0]
8080
ys = np.sin(xs) + 10
81-
ys = np.cos(xs) + 5
8281
sine2 = np.dstack([xs, ys])[0]
82+
ys = np.cos(xs) + 5
8383
cosine = np.dstack([xs, ys])[0]
8484
# creating plot
8585
plot = Plot()
8686
# creating a line collection using the sine and cosine wave data
87-
line_collection = LineCollection(data=[sine, cosine, sine2], cmap=["Oranges", "Blues"], thickness=20.0)
87+
line_collection = LineCollection(data=[sine, cosine, sine2], cmap=["Oranges", "Blues", "Reds"], thickness=20.0)
8888
# add graphic to plot
8989
plot.add_graphic(line_collection)
9090
# show plot
@@ -307,7 +307,30 @@ def __init__(
307307
308308
Examples
309309
--------
310+
.. code-block:: python
310311
312+
from fastplotlib import Plot
313+
from fastplotlib.graphics import LineStack
314+
# create line data
315+
xs = np.linspace(-10, 10, 100)
316+
ys = np.sin(xs)
317+
sine = np.dstack([xs, ys])[0]
318+
ys = np.sin(xs) + 10
319+
sine2 = np.dstack([xs, ys])[0]
320+
ys = np.cos(xs) + 5
321+
cosine = np.dstack([xs, ys])[0]
322+
# create line stack
323+
line_stack = LineStack(data=[sine, cosine, sine2], cmap=["Oranges", "Blues", "Reds"], thickness=20.0)
324+
# add graphic to plot
325+
plot.add_graphic(line_stack)
326+
# show plot
327+
plot.show()
328+
# change the color of the sine wave to white
329+
line_stack[0].colors = "w"
330+
# change certain color indexes of the cosine data to red
331+
line_stack[1].colors[0:15] = "r"
332+
# can also do slicing
333+
line_stack[2].colors[35:70] = "magenta"
311334
312335
"""
313336
super(LineStack, self).__init__(

fastplotlib/layouts/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
``PanZoomController`` type is used for 2D pan-zoom camera control and ``OrbitController`` type is used for
3939
rotating the camera around a center position, used to control the camera
4040
scene: pygfx Scene
41-
represents the root of a scene graph, will have a ``camera`` being controlled by a ``controller``
41+
represents the root of a scene graph, will be viewed by the given ``camera``
4242
canvas: WgpuCanvas
4343
provides surface on which a scene will be rendered
4444
renderer: WgpuRenderer

fastplotlib/layouts/_subplot.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ def __init__(
2828
**kwargs
2929
):
3030
"""
31-
General plot object that comprises ``Gridplot``. Each ``Gridplot`` instance will have [n rows, n columns]
31+
General plot object that composes a ``Gridplot``. Each ``Gridplot`` instance will have [n rows, n columns]
3232
of subplots.
3333
3434
Parameters
3535
----------
3636
position: int tuple, optional
3737
corresponds to the [row, column] position of the subplot within a ``Gridplot``
3838
parent_dims: int tuple, optional
39-
dimensions of parent ``PlotArea``, used in determining size of subplot to create ``DockedViewports`` on
40-
all sides of the subplot
39+
dimensions of the parent ``GridPlot``
4140
camera: str, default '2d'
4241
indicates the kind of pygfx camera that will be instantiated, '2d' uses pygfx ``OrthographicCamera`` and
4342
'3d' uses pygfx ``PerspectiveCamera``
@@ -128,7 +127,7 @@ def _create_graphic(self, graphic_class, *args, **kwargs):
128127
return graphic
129128

130129
def set_title(self, text: Any):
131-
"""Adds the name of a subplot to 'top' viewport if defined."""
130+
"""Sets the name of a subplot to 'top' viewport if defined."""
132131
if text is None:
133132
return
134133

@@ -154,7 +153,7 @@ def center_title(self):
154153
self._title_graphic.world_object.position.y = -3.5
155154

156155
def get_rect(self):
157-
"""Returns the size of a subplot."""
156+
"""Returns the bounding box that defines the Subplot within the canvas."""
158157
row_ix, col_ix = self.position
159158
width_canvas, height_canvas = self.renderer.logical_size
160159

0 commit comments

Comments
 (0)