You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/user_guide/guide.rst
+54-17Lines changed: 54 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,8 @@ What is `fastplotlib`?
22
22
23
23
`fastplotlib` is a cutting-edge plotting library built using the `pygfx <https://github.com/pygfx/pygfx>`_ rendering engine.
24
24
The lower-level details of the rendering process (i.e. defining a scene, camera, renderer, etc.) are abstracted away, allowing users to focus on their data.
25
-
The fundamental goal of `fastplotlib` is to provide a high-level, expressive API that promotes large-scale explorative scientific visualization.
25
+
The fundamental goal of `fastplotlib` is to provide a high-level, expressive API that promotes large-scale explorative scientific visualization. We want to
26
+
make it easy and intuitive to produce interactive visualizations that are as performant and vibrant as a modern video game :D
26
27
27
28
28
29
How to use `fastplotlib`
@@ -31,11 +32,11 @@ How to use `fastplotlib`
31
32
Before giving a detailed overview of the library, here is a minimal example::
32
33
33
34
import fastplotlib as fpl
34
-
import numpy as np
35
+
import imageio.v3 as iio
35
36
36
37
fig = fpl.Figure()
37
38
38
-
data = np.random.rand(512, 512)
39
+
data = iio.imread("imageio:astronaut.png")
39
40
40
41
image_graphic = fig[0,0].add_image(data=data)
41
42
@@ -44,7 +45,7 @@ Before giving a detailed overview of the library, here is a minimal example::
44
45
if __name__ == "__main__":
45
46
fpl.run()
46
47
47
-
..image:: /_static/guide_hello_world.png
48
+
..
48
49
49
50
50
51
This is just a simple example of how the `fastplotlib` API works to create a plot, add some image data to the plot, and then visualize it.
@@ -53,28 +54,31 @@ Next, we will take a look at the building blocks of `fastplotlib` and how they c
53
54
54
55
**Figure**
55
56
56
-
The base of any visualization in `fastplotlib` is a `Figure` object. This can be a singular plot or a grid of subplots.
57
+
The starting for creating any visualization in `fastplotlib` is a `Figure` object. This can be a single plot or a grid of subplots.
57
58
The `Figure` object houses and takes care of the underlying rendering components such as the camera, controller, renderer, and canvas.
59
+
Most users won't need to use these directly; however, the ability to directly interact with the rendering engine is still available if
60
+
needed.
58
61
59
62
After defining a `Figure`, we can begin to add `Graphic` objects.
60
63
61
64
**Graphics**
62
65
63
-
A `Graphic` can be an image, a line, a scatter, a collection of lines, and more. All graphics can be given a string name. This allows graphics
66
+
A `Graphic` can be an image, a line, a scatter, a collection of lines, and more. All graphics can be given a convenient ``name``. This allows graphics
Graphics also have mutable, indexable properties that can be linked to events.
80
+
Graphics also have mutable properties that can be linked to events. Some of these properties, such as the `data` or `colors` of a line can even be indexed,
81
+
allowing for the creation of very powerful visualizations.
78
82
79
83
(1) Common properties
80
84
@@ -152,20 +156,20 @@ Graphics also have mutable, indexable properties that can be linked to events.
152
156
| outline_thickness | thickness of the text |
153
157
+-------------------+---------------------------+
154
158
155
-
Using our example from above: once we add a `Graphic` to the figure, we can then begin to change its features. ::
159
+
Using our example from above: once we add a `Graphic` to the figure, we can then begin to change its properties. ::
156
160
157
-
image_graphic.cmap = "viridis"
161
+
image_graphic.vmax = "150"
158
162
159
-
..image:: /_static/guide_image_cmap.png
163
+
..
160
164
161
-
`GraphicFeatures` also support slicing and indexing. For example ::
165
+
`Graphic` properties also support slicing and indexing. For example ::
162
166
163
-
image_graphic.data[::15] = 1
164
-
image_graphic.data[15::] = 1
167
+
image_graphic.data[::8, :, :] = 1
168
+
image_graphic.data[:, ::8, :] = 1
165
169
166
-
..image:: /_static/guide_image_slice.png
170
+
..
167
171
168
-
Now that we have the basics of creating a `Figure`, adding `Graphics` to the `Figure`, and working with `GraphicFeatures` to change or alter a `Graphic`.
172
+
Now we have the basics of creating a `Figure`, adding `Graphics` to a `Figure`, and working with `Graphic` properties to dynamically change or alter them.
169
173
Let's take a look at how we can define events to link `Graphics` and their properties together.
170
174
171
175
Events
@@ -200,8 +204,41 @@ Selectors
200
204
`ImageWidget`
201
205
-------------
202
206
207
+
Often times, developing UIs for interacting with multi-dimension image data can be tedious and repetitive. In order to alleviate the headache that accompanies
208
+
constantly recreating visualizations, we created an `ImageWidget` that automatically generates sliders and
209
+
203
210
Animations
204
211
----------
205
212
213
+
An animation function is a user-defined function that gets called on every rendering cycle. Let's look at an example: ::
214
+
215
+
import fastplotlib as fpl
216
+
import numpy as np
217
+
218
+
data = np.random.rand(512, 512)
219
+
220
+
fig = fpl.Figure()
221
+
222
+
fig[0,0].add_image(data=data, name="random-img")
223
+
224
+
def update_data(plot_instance):
225
+
new_data = np.random.rand(512, 512)
226
+
plot_instance["random-img"].data = new_data
227
+
228
+
fig[0,0].add_animations(update_data)
229
+
230
+
fig.show()
231
+
232
+
..
233
+
234
+
Here we are defining a function that updates the data of the `ImageGraphic` in the plot with new random data. When adding an animation function, the
235
+
user-defined function will receive a plot instance as an argument when it is called.
0 commit comments