I came across python behavior that I would like to understand. Take a look at the following lines.
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,1,100)
plt.plot(x, x, 'k', color=None)
plt.plot(x, x**2, 'k', color=None)
According to the matplotlib documentation the plot-kwargs are defined in the Line2D class. There, we find that color takes 'None' as default argument. Hence the plot ought to be black and white. However, the output is colorful.
If I remove the optional color argument, I get black lines. So my question is, why is the above plot colored, even though I passed None as a color-option?
Edit: I understand that removing color=None leads to 'k' being used as the color option. However, I would like to understand how matplotlib internally can distuingish between
plt.plot(x, x, 'k', color=None)
and
plt.plot(x, x, 'k')
if the color argument is None by default. (Which it is according to the documentation.)

Noneas the default argument indicates to matplotlib that a value for thecolorargument was not specified, so default values are used. It is not for disabling colour.def foo(a=None). I don't see how it could be possible to find out weather I call it asfoo()orfoo(a=None). But apparently, matplotlib can distinguish between these two calls as it shifts from colorful to black and white. Do you know why?def foo(a=None)then yes, the two calls are equivalent. If instead it is defined asdef foo(**kwargs),kwargswill be an empty dictionary forfoo(), and{'a': None}forfoo(a=None). The behaviour is then up to how the function handleskwargs