Hey team,
I was reading the matplotlib documentation and got stuck on this part:
https://matplotlib.org/stable/users/explain/quick_start.html#making-a-helper-functions
Would it be better if the helper function always returns plt.Axis
? Something like this:
def my_plotter(ax: plt.Axes, data1: list, data2: list, param_dict={}) -> plt.Axes:
"""
A helper function to make a graph.
"""
ax.plot(data1, data2, **param_dict)
ax.scatter(data1, data2, **param_dict)
ax.fill(data1, data2, **param_dict)
return ax
The problem with the current implementation is that it always returns something different, e.g., [<matplotlib.lines.Line2D object at 0x1179fa960>]
in case of ax.plot()
, <matplotlib.collections.PathCollection object at 0x1179c3680>
in case of ax.scatter()
, or [<matplotlib.patches.Polygon object at 0x11786e990>]
in case of ax.fill()
. I found it a bit confusing that the return type of the function always changes.
What do you think?