Strange error with matplotlib axes labels

I had this same issue when working in iPython notebook.

I think it can be re-created as follows:

import matplotlib.pyplot as plt
plt.ylabel = 'somestring' # oh wait this isn't the right syntax.
... 
plt.ylabel('somestring') # now this breaks because the function has been turned into a string

Re-starting the kernel or re-importing the libraries restores plt.ylabel to a function.


EDIT: This code works fine for clean runs, but you might have changed ylabel, in which case restarting should fix it, as @wolfins answered (check that answer).

I'm afraid I can't tell you what's going wrong because it works fine here. The below code runs without error and shows the plot with correct label.

from matplotlib import pyplot, pylab
a = [1, 2, 3, 4, 5]
b = [2, 3, 2, 3, 2]
pyplot.plot(a, b)
pylab.xlabel("Time")
pylab.ylabel("Speed")
pyplot.show()

If that doesn't work for you, perhaps you can try using figure and axes objects, like this

from matplotlib.pyplot import subplots, show
a = [1, 2, 3, 4, 5]
b = [2, 3, 2, 3, 2]
fig, ax = subplots()
ax.plot(a, b)
ax.set_xlabel("Time")
ax.set_ylabel("Speed")
show()

Doesn't solve the underlying problem (which is hard since I can't reproduce it), but maybe it will achieve your purpose at least.