pygfx icon indicating copy to clipboard operation
pygfx copied to clipboard

Plotting

Open almarklein opened this issue 4 years ago • 4 comments

Once we have text (#20) we can think about supporting plot-like visualizations. Some things that we'd need:

  • Logic to determine the ticks.
  • Grids (infinite, showing lines and sublines at predefined intervals).
  • Colorbars.
  • Labels, titles, legend.
  • A layout engine.

More meta, where do we implement this all?

  • In pygfx itself?
  • In something like pygfx.plot?
  • We don't. We provide the lower level primitives, and a higher level plotting lib would implement it.

Somewhat related to #178.

almarklein avatar Oct 22 '21 22:10 almarklein

We don't. We provide the lower level primitives, and a higher level plotting lib would implement it.

This! :)

Korijn avatar Oct 28 '21 07:10 Korijn

Maybe you can convince @rougier to give it a shot ;-)

ivoflipse avatar Oct 28 '21 08:10 ivoflipse

We're on it actually. I like the idea of separating the lower level primitives from the higher level plotting API. But this requires some work on how to properly define the high level API such that it can benefits from the lower level primitives.

rougier avatar Oct 30 '21 08:10 rougier

I'm wondering which low level primitives you were thinking of? In fastplotlib I recently took advantage of how buffer data, such as Geometry vertex color data, can be modified and then update_range() can be used to mark only those changes. For the user it's just slicing.

For example, with a line: image

# slicing to change colors
cosine_graphic.colors[:15] = "magenta"
cosine_graphic.colors[70:] = "blue"
cosine_graphic.colors[60] = "w"
cosine_graphic.colors[25:55:3] = "cyan"
cosine_graphic.colors[75:90, 0] = np.linspace(0, 1, 15)

image

Events handlers can also be added to them:

cosine_graphic.colors.add_event_handler(print)

It's really nice that pygfx makes this possible :D

kushalkolar avatar Dec 23 '22 02:12 kushalkolar