From a comment in #572
- _setup_linked_home_buttons monkeypatches the matplotlib Figure. It stashes fig._plopp_home_data = {'callbacks': [...], 'toolbars': [...]} on a third-party object and appends to it on every figure construction, with no cleanup. Repeatedly creating Plopp figures over the same mpl figure grows these lists unbounded, and a copy() re-registers. It works for the subplots case, but it's a leaky global keyed on a private attr. Worth at least de-duplicating, and ideally not storing mutable state on the mpl figure.
I'm starting to wonder if we should re-organise things around how the figure is built. Also considering #571 (comment).
Maybe we should also have a concept of axes in our figures, and work more like MPL?
A figure could hold multiple Views (which would be like the axes) and then updating all of them with one button would be much cleaner.
I don't really know what the syntax would look like if you want to create a figure with mpl axes. Maybe one way is to add the different ways mpl does it in Plopp itself?
For example we could mirror the plt.subplots function, and/or we could support things like
fig = pp.Figure()
ax0 = fig.add_axes([0.0, 0.2, 1.0, 0.8])
ax1 = fig.add_axes([0.0, 0.0, 1.0, 0.2])
ax0.plot(da_1d) # --> returns None
ax1.plot(da_2d) # --> returns None
fig # display the figure
Or some other syntax.
The point being that we almost never need to create any axes via matplotlib?
But then we get into questions about what happens if you plot twice in a row on the same axes:
does it overwrite what was on the axes, or does it just add to the plot?
If we add incompatible data, should it raise? (the current update mechanism on a view raises).
From a comment in #572
I'm starting to wonder if we should re-organise things around how the figure is built. Also considering #571 (comment).
Maybe we should also have a concept of axes in our figures, and work more like MPL?
A figure could hold multiple
Views (which would be like the axes) and then updating all of them with one button would be much cleaner.I don't really know what the syntax would look like if you want to create a figure with mpl axes. Maybe one way is to add the different ways mpl does it in Plopp itself?
For example we could mirror the
plt.subplotsfunction, and/or we could support things likeOr some other syntax.
The point being that we almost never need to create any axes via matplotlib?
But then we get into questions about what happens if you plot twice in a row on the same axes:
does it overwrite what was on the axes, or does it just add to the plot?
If we add incompatible data, should it raise? (the current
updatemechanism on a view raises).