title: Matplotlib - Passing an equation through a parameter into a function
body: <p>I am writing a program where the user enters a mathematical equation (e.g. x^2 + 2x + 2) and the function plotFunction will plot it out on a graph using matplotlib.
  When I enter a parameter such as &quot;x<strong>2&quot; it returns the error:
  ValueError: Illegal format string &quot;x</strong>2&quot;; two marker symbols</p>
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  class Plotter:
      def __init__(self):
          pass
          
                  
      def plotFunction(self, func):     
          x = np.arange(-100, 100)
         
          y = func
          plt.plot(x, y)
          plt.show()
  
  p1 = Plotter()
  p1.plotFunction(&quot;x**2&quot;)
  </code></pre>