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 5e4a594

Browse filesBrowse files
committed
progress on guide
1 parent f788654 commit 5e4a594
Copy full SHA for 5e4a594

File tree

Expand file treeCollapse file tree

1 file changed

+54
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+54
-17
lines changed

‎docs/source/user_guide/guide.rst

Copy file name to clipboardExpand all lines: docs/source/user_guide/guide.rst
+54-17Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ What is `fastplotlib`?
2222

2323
`fastplotlib` is a cutting-edge plotting library built using the `pygfx <https://github.com/pygfx/pygfx>`_ rendering engine.
2424
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
2627

2728

2829
How to use `fastplotlib`
@@ -31,11 +32,11 @@ How to use `fastplotlib`
3132
Before giving a detailed overview of the library, here is a minimal example::
3233

3334
import fastplotlib as fpl
34-
import numpy as np
35+
import imageio.v3 as iio
3536

3637
fig = fpl.Figure()
3738

38-
data = np.random.rand(512, 512)
39+
data = iio.imread("imageio:astronaut.png")
3940

4041
image_graphic = fig[0,0].add_image(data=data)
4142

@@ -44,7 +45,7 @@ Before giving a detailed overview of the library, here is a minimal example::
4445
if __name__ == "__main__":
4546
fpl.run()
4647

47-
.. image:: /_static/guide_hello_world.png
48+
..
4849
4950

5051
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
5354

5455
**Figure**
5556

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.
5758
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.
5861

5962
After defining a `Figure`, we can begin to add `Graphic` objects.
6063

6164
**Graphics**
6265

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
6467
to be easily accessed from figures::
6568

6669
fig = fpl.Figure()
6770

6871
data = np.random.rand(512, 512)
6972

70-
image_graphic = fig[0,0].add_image(data=data, name="random-img")
73+
image_graphic = fig[0,0].add_image(data=data, name="astronaut")
7174

7275
fig.show()
7376

74-
fig[0,0]["random-img"]
77+
fig[0,0]["astronaut"]
7578
..
7679
77-
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.
7882

7983
(1) Common properties
8084

@@ -152,20 +156,20 @@ Graphics also have mutable, indexable properties that can be linked to events.
152156
| outline_thickness | thickness of the text |
153157
+-------------------+---------------------------+
154158

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. ::
156160

157-
image_graphic.cmap = "viridis"
161+
image_graphic.vmax = "150"
158162

159-
.. image:: /_static/guide_image_cmap.png
163+
..
160164
161-
`GraphicFeatures` also support slicing and indexing. For example ::
165+
`Graphic` properties also support slicing and indexing. For example ::
162166

163-
image_graphic.data[::15] = 1
164-
image_graphic.data[15::] = 1
167+
image_graphic.data[::8, :, :] = 1
168+
image_graphic.data[:, ::8, :] = 1
165169

166-
.. image:: /_static/guide_image_slice.png
170+
..
167171
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.
169173
Let's take a look at how we can define events to link `Graphics` and their properties together.
170174

171175
Events
@@ -200,8 +204,41 @@ Selectors
200204
`ImageWidget`
201205
-------------
202206

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+
203210
Animations
204211
----------
205212

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.
236+
237+
Spaces
238+
------
239+
240+
241+
Using `fastplotlib` interactively
242+
---------------------------------
206243

207244

0 commit comments

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