I have a function in my code that takes an Axes-instance to plot on. I want to set the default to be the current axis. This leads to the followig code:
from matplotlib import pyplot as plt
def plotfunc(ax=plt.gca()):
# Here I would usually plot some functions on ax
return True
plt.figure()
plt.show()
What I would expect from this script is one blank figure showing up. But what I get is one figure and another empty subplot, although I din't even call plotfunc. The additional subplot doesn't appear when I delete the "=plt.cga()" part in the code. Is there a way to set pltgca() as the standard axis for plotfunc without getting another subplot?
I'm using python 3.6 under Ubuntu 18.04.1.