Skip to content
Advertisement

How to customize and add extra elements to Sympy plots?

I have a few questions about what how to work with graphics, using Sympy.

My code:

JavaScript

1) The graph is obtained stretched along the x axis.

enter image description here

How to make so that the curve looked like a circle?

2) How to add other elements to the chart. For example, the point O(0, 0) and the line y = x.

enter image description here

Advertisement

Answer

According to the docstring of plot.py, you can get the backend wrapper of the Matplotlib axes and figure that SymPy uses, through _backend attribute, and then modify properties as any other Matplotlib objects. Check this example:

JavaScript

The Sympy Plot objects have append and extend methods that allows add a Plot object to other, but this don’t work (at least for me and using Jupyter).

Another option is use only Matplotlib:

JavaScript
Advertisement