Content-Length: 1046236 | pFad | http://github.com/fastplotlib/fastplotlib/commit/0de38a7f2648aab23657b27bd418b18a524283f3

1C docstring and docs cleanup, other misc small things (#828) · fastplotlib/fastplotlib@0de38a7 · GitHub
Skip to content

Commit 0de38a7

Browse files
kushalkolarclewis7
andauthored
docstring and docs cleanup, other misc small things (#828)
* rename cleanup, docstring cleanup * docstring cleanup * docstrings * more docstring * docstring * image docstrings * scatter docstrings * rename * text docstrings * yet more docstrings * another gridplot rename * better Figure names handling * properly remove padding kwarg * update quickstart.ipynb * black * Update fastplotlib/graphics/image.py Co-authored-by: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> * better names logic * update example * sphinx is annoying * update add_graphic methods mixin * update generate script --------- Co-authored-by: Caitlin Lewis <69729525+clewis7@users.noreply.github.com>
1 parent 0e1a308 commit 0de38a7

21 files changed

+328
-167
lines changed

examples/controllers/specify_integers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
[2, 0],
2525
]
2626

27-
names = [f"contr. id: {i}" for i in np.asarray(ids).ravel()]
28-
2927
figure = fpl.Figure(
3028
shape=(2, 2),
3129
controller_ids=ids,
32-
names=names,
3330
size=(700, 560),
3431
)
3532

33+
for subplot, controller_id in zip(figure, np.asarray(ids).ravel()):
34+
subplot.title = f"contr. id: {controller_id}"
35+
3636
figure[0, 0].add_line(np.column_stack([xs, sine]))
3737

3838
figure[0, 1].add_line(np.random.rand(100))

examples/gridplot/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
GridPlot Examples
2-
=================
1+
Grid layout Examples
2+
====================

examples/gridplot/gridplot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
GridPlot Simple
3-
===============
2+
Grid layout Simple
3+
==================
44
5-
Example showing simple 2x2 GridPlot with Standard images from imageio.
5+
Example showing simple 2x2 grid layout with standard images from imageio.
66
"""
77

88
# test_example = true

examples/gridplot/gridplot_non_square.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
GridPlot Non-Square Example
3-
===========================
2+
Grid Layout 2
3+
=============
44
5-
Example showing simple 2x2 GridPlot with Standard images from imageio.
5+
Simple 2x2 grid layout Figure with standard images from imageio, one subplot is left empty
66
"""
77

88
# test_example = true

examples/gridplot/gridplot_viewports_check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
GridPlot test viewport rects
3-
============================
2+
Grid layout test viewport rects
3+
===============================
44
55
Test figure to test that viewport rects are positioned correctly
66
"""

examples/gridplot/multigraphic_gridplot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
Multi-Graphic GridPlot
3-
======================
2+
Multi-Graphic Grid layout
3+
=========================
44
5-
Example showing a Figure with multiple subplots and multiple graphic types.
5+
A Figure with multiple subplots and multiple graphic types.
66
"""
77

88
# test_example = false

examples/misc/multiplot_animation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Multi-Subplot Image Update
33
==========================
44
5-
Example showing updating a multiple subplots with new random 512x512 data.
5+
Multiple subplots with an image that updates with new data on every render.
66
"""
77

88
# test_example = false
@@ -27,7 +27,7 @@
2727
figure[1,1]["rand-img"].cmap = "spring"
2828

2929
# Define a function to update the image graphics with new data
30-
# add_animations will pass the gridplot to the animation function
30+
# add_animations will pass the figure to the animation function
3131
def update_data(f):
3232
for subplot in f:
3333
new_data = np.random.rand(512, 512)
@@ -37,7 +37,7 @@ def update_data(f):
3737
# add the animation function
3838
figure.add_animations(update_data)
3939

40-
# show the gridplot
40+
# show the figure
4141
figure.show()
4242

4343

examples/notebooks/quickstart.ipynb

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@
463463
"id": "5694dca1-1041-4e09-a1da-85b293c5af47",
464464
"metadata": {},
465465
"source": [
466-
"### RGB images are also supported\n",
466+
"### RGB(A) images are supported\n",
467467
"\n",
468468
"`cmap` arguments are ignored for rgb images, but vmin vmax still works"
469469
]
@@ -538,7 +538,7 @@
538538
"source": [
539539
"### Image updates\n",
540540
"\n",
541-
"This examples show how you can define animation functions that run on every render cycle."
541+
"This example shows how you can define animation functions that run on every render cycle."
542542
]
543543
},
544544
{
@@ -620,15 +620,15 @@
620620
"id": "f226c9c2-8d0e-41ab-9ab9-1ae31fd91de5",
621621
"metadata": {},
622622
"source": [
623-
"#### Keeping a reference to the Graphic instance, as shown above `image_graphic_instance`, is useful if you're creating something where you need flexibility in the naming of the graphics"
623+
"#### Keeping a reference to the Graphic instance, as shown above `image_graphic_instance`, is useful if you're creating something where it is convenient to keep your own reference to a `Graphic`"
624624
]
625625
},
626626
{
627627
"cell_type": "markdown",
628628
"id": "d11fabb7-7c76-4e94-893d-80ed9ee3be3d",
629629
"metadata": {},
630630
"source": [
631-
"### You can also use `ipywidgets.VBox` and `HBox` to stack plots. See the `subplot` notebooks for more automated subplotting"
631+
"### You can also use `ipywidgets.VBox` and `HBox` to stack plots."
632632
]
633633
},
634634
{
@@ -664,7 +664,7 @@
664664
"\n",
665665
"## 2D line plots\n",
666666
"\n",
667-
"This example plots a sine wave, cosine wave, and ricker wavelet and demonstrates how **Graphic Features** can be modified by slicing!"
667+
"This example plots a sine wave, cosine wave, and ricker wavelet and demonstrates how **Graphic Properties** can be modified by slicing!"
668668
]
669669
},
670670
{
@@ -755,15 +755,15 @@
755755
"\n",
756756
"Set `maintain_aspect = False` on a camera, and then use the right mouse button and move the mouse to stretch and squeeze the view!\n",
757757
"\n",
758-
"You can also click the **`1:1`** button to toggle this, or use `subplot.camera.maintain_aspect`"
758+
"You can also click the **``** button to toggle this, or use `subplot.camera.maintain_aspect`"
759759
]
760760
},
761761
{
762762
"cell_type": "markdown",
763763
"id": "1651e965-f750-47ac-bf53-c23dae84cc98",
764764
"metadata": {},
765765
"source": [
766-
"### reset the plot area"
766+
"### reset the plot area camera"
767767
]
768768
},
769769
{
@@ -783,7 +783,9 @@
783783
"id": "dcd68796-c190-4c3f-8519-d73b98ff6367",
784784
"metadata": {},
785785
"source": [
786-
"## Graphic features support slicing! :D "
786+
"## Graphic properties support slicing! :D\n",
787+
"\n",
788+
"Data, colors, and cmaps can often be sliced just like arrays to set or get values!"
787789
]
788790
},
789791
{
@@ -811,7 +813,7 @@
811813
"id": "c9689887-cdf3-4a4d-948f-7efdb09bde4e",
812814
"metadata": {},
813815
"source": [
814-
"## You can capture changes to a graphic feature as events"
816+
"## Graphic properties are _evented_, so you can capture when they change"
815817
]
816818
},
817819
{
@@ -1551,7 +1553,7 @@
15511553
" subplot.add_image(data, name=\"rand-img\")\n",
15521554
"\n",
15531555
"# Define a function to update the image graphics with new data\n",
1554-
"# add_animations will pass the gridplot to the animation function\n",
1556+
"# add_animations will pass the figure to the animation function\n",
15551557
"def update_data(f):\n",
15561558
" for subplot in f:\n",
15571559
" new_data = np.random.rand(512, 512)\n",
@@ -1561,7 +1563,7 @@
15611563
"# add the animation function\n",
15621564
"figure_grid.add_animations(update_data)\n",
15631565
"\n",
1564-
"# show the gridplot\n",
1566+
"# show the figure\n",
15651567
"figure_grid.show()"
15661568
]
15671569
},
@@ -1575,7 +1577,7 @@
15751577
}
15761578
},
15771579
"source": [
1578-
"### Slicing GridPlot"
1580+
"### Slicing a grid layout to get subplots"
15791581
]
15801582
},
15811583
{
@@ -1605,7 +1607,7 @@
16051607
}
16061608
},
16071609
"source": [
1608-
"You can get the graphics within a subplot, just like with simple `Plot`"
1610+
"You can get the graphics within a subplot"
16091611
]
16101612
},
16111613
{
@@ -1661,7 +1663,7 @@
16611663
}
16621664
},
16631665
"source": [
1664-
"more slicing with `GridPlot`"
1666+
"more slicing with a `Figure` that has a grid layout"
16651667
]
16661668
},
16671669
{
@@ -1707,7 +1709,7 @@
17071709
},
17081710
"outputs": [],
17091711
"source": [
1710-
"# these are really the same\n",
1712+
"# these are the same\n",
17111713
"figure_grid[\"top-right-plot\"] is figure_grid[0, 2]"
17121714
]
17131715
},
@@ -1749,7 +1751,7 @@
17491751
}
17501752
},
17511753
"source": [
1752-
"## Figure subplot customization"
1754+
"## Figure subplot customization in a grid layout"
17531755
]
17541756
},
17551757
{
@@ -1776,13 +1778,13 @@
17761778
"]\n",
17771779
"\n",
17781780
"\n",
1779-
"# you can give string names for each subplot within the gridplot\n",
1781+
"# you can give string names for each subplot within the figure\n",
17801782
"names = [\n",
17811783
" [\"subplot0\", \"subplot1\", \"subplot2\"],\n",
17821784
" [\"subplot3\", \"subplot4\", \"subplot5\"]\n",
17831785
"]\n",
17841786
"\n",
1785-
"# Create the grid plot\n",
1787+
"# Create the figure\n",
17861788
"figure_grid = fpl.Figure(\n",
17871789
" shape=shape,\n",
17881790
" controller_ids=controller_ids,\n",
@@ -1819,7 +1821,7 @@
18191821
}
18201822
},
18211823
"source": [
1822-
"Indexing the gridplot to access subplots"
1824+
"Slicing/indexing the figure to get subplots"
18231825
]
18241826
},
18251827
{
@@ -1834,7 +1836,7 @@
18341836
},
18351837
"outputs": [],
18361838
"source": [
1837-
"# can access subplot by name\n",
1839+
"# get subplot by name\n",
18381840
"figure_grid[\"subplot0\"]"
18391841
]
18401842
},
@@ -1850,7 +1852,7 @@
18501852
},
18511853
"outputs": [],
18521854
"source": [
1853-
"# can access subplot by index\n",
1855+
"# or get subplot by index\n",
18541856
"figure_grid[0, 0]"
18551857
]
18561858
},
@@ -1864,7 +1866,7 @@
18641866
}
18651867
},
18661868
"source": [
1867-
"**subplots also support indexing!**\n",
1869+
"**from before, remember subplots themselves also support slicing to get graphics within them!**\n",
18681870
"\n",
18691871
"this can be used to get graphics if they are named"
18701872
]
@@ -1885,6 +1887,17 @@
18851887
"figure_grid[\"subplot0\"][\"rand-image\"]"
18861888
]
18871889
},
1890+
{
1891+
"cell_type": "code",
1892+
"execution_count": null,
1893+
"id": "87905450bdc0ec0a",
1894+
"metadata": {},
1895+
"outputs": [],
1896+
"source": [
1897+
"# or by their numerical index\n",
1898+
"figure_grid[\"subplot0\"].graphics[0]"
1899+
]
1900+
},
18881901
{
18891902
"cell_type": "code",
18901903
"execution_count": null,
@@ -1911,7 +1924,7 @@
19111924
}
19121925
},
19131926
"source": [
1914-
"positional indexing also works event if subplots have string names"
1927+
"positional indexing also works even if subplots have string names"
19151928
]
19161929
},
19171930
{

examples/scatter/scatter_size.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
Scatter Plot Size
33
=================
44
5-
Example showing point size change for scatter plot.
5+
Example that shows how to set scatter sizes in two different ways.
6+
7+
One subplot uses a single scaler value for every point, and another subplot uses an array that defines the size for
8+
each individual scatter point.
69
"""
710

811
# test_example = true
@@ -14,10 +17,10 @@
1417
# figure with 2 rows and 3 columns
1518
shape = (2, 1)
1619

17-
# you can give string names for each subplot within the gridplot
20+
# you can give string names for each subplot within the figure
1821
names = [["scalar_size"], ["array_size"]]
1922

20-
# Create the grid plot
23+
# Create the figure
2124
figure = fpl.Figure(shape=shape, names=names, size=(700, 560))
2225

2326
# get y_values using sin function

fastplotlib/graphics/_positions_base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PositionsGraphic(Graphic):
1919

2020
@property
2121
def data(self) -> VertexPositions:
22-
"""Get or set the vertex positions data"""
22+
"""Get or set the graphic's data"""
2323
return self._data
2424

2525
@data.setter
@@ -28,7 +28,7 @@ def data(self, value):
2828

2929
@property
3030
def colors(self) -> VertexColors | pygfx.Color:
31-
"""Get or set the colors data"""
31+
"""Get or set the colors"""
3232
if isinstance(self._colors, VertexColors):
3333
return self._colors
3434

@@ -45,7 +45,11 @@ def colors(self, value: str | np.ndarray | tuple[float] | list[float] | list[str
4545

4646
@property
4747
def cmap(self) -> VertexCmap:
48-
"""Control the cmap, cmap transform, or cmap alpha"""
48+
"""
49+
Control the cmap, cmap transform, or cmap alpha
50+
51+
For supported colormaps see the ``cmap`` library catalogue: https://cmap-docs.readthedocs.io/en/stable/catalog/
52+
"""
4953
return self._cmap
5054

5155
@cmap.setter

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/fastplotlib/fastplotlib/commit/0de38a7f2648aab23657b27bd418b18a524283f3

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy