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 ax
See also histpy and mhealpy for more examples.
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 likeInternally, the plotting function should look like:
See also histpy and mhealpy for more examples.