When I want to plot a curve f(x)
with pyplot, what I usually do is to create a vector X with all the x-values equally spaced:
import numpy as np
X=np.linspace(0.,1.,100)
then I create the function
def f(x):
return x**2
and then I make the plot
from matplotlib import pyplot as plt
plt.plot(X,f(X))
plt.show()
However, in some cases I might want the x-values not to be equally spaced, when the function is very stiff in some regions and very smooth in others.
What is the correct way to properly choose the best X
vector for the function I want to plot?