I've been playing around with pyplot and some things are just weird.
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return x**2
def g(x):
return 5
def h(x):
return 5+x-x
x = np.linspace(-3.0, 3.0, num=50)
plt.plot(x, f(x)) #works
plt.plot(x, g(x)) #crashes
plt.plot(x, h(x)) #works
plt.grid()
plt.show()
f(x) works as expected. g(x) crashes and to draw a line I have to use the workaround in h(x). Why is that? All of these functions only return numbers but one works and the other doesn't.