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
Currently everything is basically imported at top level, it could get messy if we expand to include more widgets for example. Currently Image and ImageWidget exist.
Only the following should exist at the top level:
graphics
layouts
Plot
widgets
For quick simple plots they just use Plot(), for everything else they do something like:
fromfastplotlib.graphicsimportImage, Linefromfastplotlib.layoutsimportGridPlot# or for widget plotsfromfastplotlib.widgetsimportImageWidget
I think we should try and minimize the number of imports that have to be written, try to avoid becoming messy like bokeh. Maybe have the widgets importable at top level since those will probably be used more frequently. Should see what we come up with for the events system as well in #39 and see where that will go.
This sounds like a good strategy to me! The one question I have here is where the line is between things that would fall into the Plot and graphics functionality. E.g., again with my usual thought: try to emulate matplotlib where it is strong, but break from it where it is not (and where people don't really use it much anyway).
import fastplotlib.Plot as plot
plot = Plot()
plot.scatter() #does a scatter plot
plot.plot() # plots a line (don't make ppl think about what special objects are needed)
plot.imshow() # again, just let people do what they already expect
But then for special widgets with a ui component, you need widgets because matplotlib is not great, so you have special things for that, because you don't want to emulate matplotlib.
Anyway, just thinking out loud here as usual. I may well be wrong, esp as I am not yet a power user of fastplotlib.
Kind of, this is how the simple plot functionality works:
fromfastplotlibimportPlot()
plot=Plot() # create a plotterplot.image() # image plotplot.line() # line plot, put on the same canvas since we're using the same plot instanceplot.scatter() # scatter plot, put on top of the previous
... etc.
It's similar to matplotlib but I think a bit more explicity, image, line, scatter are the same exact names as the Graphic classes. That's how it's actually implemented in the Plot class anyways and probably makes it easy for a user to go between the simple Plot interfaces and Graphics if necessary.
For widgets, currently the image widget works like this:
fromfastplotlib.widgetsimportImageWidgetiw=ImageWidget(data=<data>, cmap="plasma")
# if it's a single data array, they can access the `Plot` instance of the imagewidget and add more thingsiw.plot.line(data=<somelinedata>)
Just using with recent changes, it seems there are a lot of imports I'm doing right now, e.g.,:
from fastplotlib import Plot
from fastplotlib.layouts import GridPlot
from fastplotlib.graphics import ImageGraphic
This seems like too much for the simplicity of what I'm trying to do.
I see the utility of having these layout/graphics things in separate modules, but I wonder if you might want to set up the package (with imports in __init__) so people can just from fastplotlib import Plot, GridPlot, Image and all the things, but also maybe more importantly for the future they can just import fastplotlib as fpl and then just use these different widgets as needed? grid_plot = fpl.GridPlot(...things..).
FOr people that like to keep things logically ordered, they could still import as above.
Activity
kushalkolar commentedon Dec 6, 2022
I think we should try and minimize the number of imports that have to be written, try to avoid becoming messy like bokeh. Maybe have the widgets importable at top level since those will probably be used more frequently. Should see what we come up with for the events system as well in #39 and see where that will go.
EricThomson commentedon Dec 6, 2022
This sounds like a good strategy to me! The one question I have here is where the line is between things that would fall into the Plot and graphics functionality. E.g., again with my usual thought: try to emulate matplotlib where it is strong, but break from it where it is not (and where people don't really use it much anyway).
But then for special widgets with a ui component, you need widgets because matplotlib is not great, so you have special things for that, because you don't want to emulate matplotlib.
Anyway, just thinking out loud here as usual. I may well be wrong, esp as I am not yet a power user of fastplotlib.
kushalkolar commentedon Dec 6, 2022
Kind of, this is how the simple plot functionality works:
It's similar to matplotlib but I think a bit more explicity,
image,line,scatterare the same exact names as theGraphicclasses. That's how it's actually implemented in thePlotclass anyways and probably makes it easy for a user to go between the simplePlotinterfaces andGraphicsif necessary.For widgets, currently the image widget works like this:
EricThomson commentedon Dec 16, 2022
Just using with recent changes, it seems there are a lot of imports I'm doing right now, e.g.,:
This seems like too much for the simplicity of what I'm trying to do.
I see the utility of having these layout/graphics things in separate modules, but I wonder if you might want to set up the package (with imports in
__init__) so people can justfrom fastplotlib import Plot, GridPlot, Imageand all the things, but also maybe more importantly for the future they can justimport fastplotlib as fpland then just use these different widgets as needed?grid_plot = fpl.GridPlot(...things..).FOr people that like to keep things logically ordered, they could still import as above.