title: Matplotlib error: "x and y must have same first dimension, but have shapes (100,) and (1,)"
body: <p>I am getting this error when i'm trying to plot a function. This is some of my code:</p>
  <pre><code>def f(x):
      return f1
  xspace=np.linspace(-3,3,100)
  plt.ylim([-3,3])
  plt.plot(xspace,f(xspace))
  </code></pre>
  <p>Where f1 is calculated previously</p>
  <pre><code>line1=x**16-1
  line2=x**24-1
  f1=sym.cancel(line1/line2)
  </code></pre>
  <p>My question is when i do return f1 i get the error above however when i write the function out longhand instead of writing f1 it works which seems weird to me as they are both the same. Do i always have to write the function out when defining it before graphing or can i set it to a variable? It seems very tedious to do this especially when i have to graph the second derivative for the next part of it.
  Thanks in advance</p>