Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e3a0b27

Browse filesBrowse files
committed
adding some more docstrings
1 parent 7352fac commit e3a0b27
Copy full SHA for e3a0b27

File tree

Expand file treeCollapse file tree

3 files changed

+89
-19
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+89
-19
lines changed

‎fastplotlib/graphics/image.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/image.py
+41-3Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Tuple
1+
from typing import *
22

33
import numpy as np
44
import pygfx
@@ -10,13 +10,52 @@
1010
class ImageGraphic(Graphic):
1111
def __init__(
1212
self,
13-
data: np.ndarray,
13+
data: Any,
1414
vmin: int = None,
1515
vmax: int = None,
1616
cmap: str = 'plasma',
1717
*args,
1818
**kwargs
1919
):
20+
"""
21+
Plot Image data.
22+
23+
Parameters
24+
----------
25+
data: array-like
26+
| array-like, usually numpy array, must support ``memoryview()``
27+
| Tensorflow Tensors also work _I think_, but not thoroughly tested
28+
29+
vmin: int, optional
30+
minimum value for color scaling, calculated from data if not provided
31+
vmax: int, optional
32+
maximum value for color scaling, calculated from data if not provided
33+
34+
cmap: str, optional
35+
colormap to use to display the image data, default is ``"plasma"``
36+
args:
37+
additional arguments passed to Graphic
38+
kwargs:
39+
additional keyword arguments passed to Graphic
40+
41+
Examples
42+
--------
43+
44+
.. code-block:: python
45+
46+
# create a `Plot` instance
47+
plot = Plot()
48+
49+
# make some random 2D image data
50+
data = np.random.rand(512, 512)
51+
52+
# plot the image data
53+
plot.add_image(data=data)
54+
55+
# show the plot
56+
plot.show()
57+
58+
"""
2059
if data.ndim != 2:
2160
raise ValueError("`data.ndim !=2`, you must pass only a 2D array to `data`")
2261

@@ -45,4 +84,3 @@ def update_data(self, data: np.ndarray):
4584
def update_cmap(self, cmap: str, alpha: float = 1.0):
4685
self.world_object.material.map = get_cmap_texture(name=cmap)
4786
self.world_object.geometry.grid.update_range((0, 0, 0), self.world_object.geometry.grid.size)
48-

‎fastplotlib/graphics/line.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/line.py
+31-1Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
1+
from typing import *
12
import numpy as np
23
import pygfx
34

45
from ._base import Graphic
56

67

78
class LineGraphic(Graphic):
8-
def __init__(self, data: np.ndarray, z_position: float = 0.0, size: float = 2.0, colors: np.ndarray = None, cmap: str = None, *args, **kwargs):
9+
def __init__(
10+
self,
11+
data: Any,
12+
z_position: float = 0.0,
13+
size: float = 2.0,
14+
colors: np.ndarray = None,
15+
cmap: str = None,
16+
*args,
17+
**kwargs
18+
):
19+
"""
20+
Plot line data, 2d or 3d
21+
22+
Parameters
23+
----------
24+
data: array-like
25+
Line data to plot, 2D must be of shape [(]n_points, 2], 3D must be of shape [n_points, 3]
26+
27+
z_position: float, optional
28+
z-axis position for placing the graphic
29+
30+
size: float, optional
31+
thickness of the line
32+
33+
colors:
34+
cmap: str, optional
35+
apply a colormap to the line instead of assigning colors manually
36+
args
37+
kwargs
38+
"""
939
super(LineGraphic, self).__init__(data, colors=colors, cmap=cmap, *args, **kwargs)
1040

1141
self.fix_data()

‎fastplotlib/layouts/_gridplot.py

Copy file name to clipboardExpand all lines: fastplotlib/layouts/_gridplot.py
+17-15Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,36 @@ def __init__(
3131
**kwargs
3232
):
3333
"""
34+
A grid of subplots
35+
3436
Parameters
3537
----------
3638
shape:
3739
nrows, ncols
3840
39-
cameras: Union[np.ndarray, str]
40-
One of ``"2d"`` or ``"3d"`` indicating 2D or 3D plots
41+
cameras: np.ndarray or str, optional
42+
| One of ``"2d"`` or ``"3d"`` indicating 2D or 3D plots
4143
42-
OR
44+
| OR
4345
44-
Array of ``2d`` and/or ``3d`` that specifies camera type for each subplot:
45-
``2d``: ``pygfx.OrthographicCamera``
46-
``3d``: ``pygfx.PerspectiveCamera``
46+
| Array of ``2d`` and/or ``3d`` that specifies camera type for each subplot:
47+
| ``2d``: ``pygfx.OrthographicCamera``
48+
| ``3d``: ``pygfx.PerspectiveCamera``
4749
48-
controllers: np.ndarray
49-
numpy array of same shape as ``grid_shape`` that defines the controllers
50-
Example:
51-
unique controllers for a 2x2 gridplot: np.array([[0, 1], [2, 3]])
52-
same controllers for first 2 plots: np.array([[0, 0, 1], [2, 3, 4]])
50+
controllers: np.ndarray or str, optional
51+
| numpy array of same shape as ``grid_shape`` that defines the controllers
52+
| Example:
53+
| unique controllers for a 2x2 gridplot: np.array([[0, 1], [2, 3]])
54+
| same controllers for first 2 plots: np.array([[0, 0, 1], [2, 3, 4]])
5355
54-
If `None` a unique controller is created for each subplot
56+
| If `None` a unique controller is created for each subplot
5557
56-
If "sync" all the subplots use the same controller
58+
| If "sync" all the subplots use the same controller
5759
58-
canvas: WgpuCanvas
60+
canvas: WgpuCanvas, optional
5961
Canvas for drawing
6062
61-
renderer: pygfx.Renderer
63+
renderer: pygfx.Renderer, optional
6264
pygfx renderer instance
6365
"""
6466
self.shape = shape

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.