-
Notifications
You must be signed in to change notification settings - Fork 34
Labels
Description
There are multiple functions in cosipy using pyplot directly e.g. plt.plot() --i.e. the stateful interface. This is OK for an user-defined or user-facing script, but not in a library, since it makes it hard to control the flow and can conflict with the user customization. See for example the issue described in #481.
Instead, all methods generating a plot should take as input a matplotlib Axes, which will be the one use to produce the plot. The user would do seomething like
# Create Axes
fig,ax = plt.subplot()
# Plot using cosipy
foo.plot(ax)
# Customize
ax.set_xlim(5,10)Internally, the plotting function should look like:
def plot(ax = None):
if ax is None:
# Create Axes it not provided
fig,ax = plt.subplots()
x,y = compute_data()
ax.plot(x,y)
return axSee also histpy and mhealpy for more examples.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
No status