I am trying to plot a function created from a string with implemented_function and lambdify. The function works for calculating single values, but not for plotting. I get an error, which states "Cannot convert expression to float" in the line of ax.plot(...). Apparently sympy and matplotlib have some conflict. The full error message is printed below. Does anyone know how to fix this? Code: import sympy as sympy from sympy import lambdify, Function, Lambda from sympy.abc import x, y, z from sympy.utilities.lambdify import implemented_function import matplotlib.pyplot as plt fig, ax = plt.subplots() plt.show() inf = implemented_function(Function('f'), lambda x: eval("x")) f = lambdify(x, inf(x)) ax.plot(x, f(x), color="blue", linestyle=":", label = "f(x)") Error Message: TypeError Traceback (most recent call last) Cell In[27], line 25 23 inf = implemented_function(Function('f'), lambda x: eval("x")) 24 f = lambdify(x, inf(x)) ---> 25 ax.plot(x, f(x), color="blue", linestyle=":", label = "f(x)") File ~\anaconda3\Lib\site-packages\matplotlib\axes\_axes.py:1781, in Axes.plot(self, scalex, scaley, data, *args, **kwargs) 1779 lines = [*self._get_lines(self, *args, data=data, **kwargs)] 1780 for line in lines: -> 1781 self.add_line(line) 1782 if scalex: 1783 self._request_autoscale_view("x") File ~\anaconda3\Lib\site-packages\matplotlib\axes\_base.py:2339, in _AxesBase.add_line(self, line) 2336 if line.get_clip_path() is None: 2337 line.set_clip_path(self.patch) -> 2339 self._update_line_limits(line) 2340 if not line.get_label(): 2341 line.set_label(f'_child{len(self._children)}') File ~\anaconda3\Lib\site-packages\matplotlib\axes\_base.py:2362, in _AxesBase._update_line_limits(self, line) 2358 def _update_line_limits(self, line): 2359 """ 2360 Figures out the data limit of the given line, updating self.dataLim. 2361 """ -> 2362 path = line.get_path() 2363 if path.vertices.size == 0: 2364 return File ~\anaconda3\Lib\site-packages\matplotlib\lines.py:1037, in Line2D.get_path(self) 1035 """Return the `~matplotlib.path.Path` associated with this line.""" 1036 if self._invalidy or self._invalidx: -> 1037 self.recache() 1038 return self._path File ~\anaconda3\Lib\site-packages\matplotlib\lines.py:674, in Line2D.recache(self, always) 672 if always or self._invalidx: 673 xconv = self.convert_xunits(self._xorig) --> 674 x = _to_unmasked_float_array(xconv).ravel() 675 else: 676 x = self._x File ~\anaconda3\Lib\site-packages\matplotlib\cbook.py:1398, in _to_unmasked_float_array(x) 1396 return np.ma.asarray(x, float).filled(np.nan) 1397 else: -> 1398 return np.asarray(x, float) File ~\anaconda3\Lib\site-packages\sympy\core\expr.py:340, in Expr.__float__(self) 338 if result.is_number and result.as_real_imag()[1]: 339 raise TypeError("Cannot convert complex to float") --> 340 raise TypeError("Cannot convert expression to float") TypeError: Cannot convert expression to float Continue reading...