Using SymPy, I can create a contour graph manually (there is no built-in contour plotting function yet) using the following code:
from sympy import init_session
init_session()
from sympy.plotting.plot import Plot, ContourSeries
x_min = -7
x_max = 7
y_min = -5
y_max = 5
my_plot = Plot(
ContourSeries(
sqrt(x**2 + y**2),
(x,x_min,x_max),
(y,y_min,y_max)
)
)
my_plot.show()

Currently, when SymPy calls contour(), it looks like it is not saving the returned ContourSet ( Update: I have a problem registered to see if ContourSet can be saved):
class MatplotlibBackend(BaseBackend):
...
def process_series(self):
...
for s in self.parent._series:
...
elif s.is_contour:
self.ax.contour(*s.get_meshes())
In other examples where modifications are made on the chart, for example, adding inline labels usingclabel() , ContourSet ( CS):
plt.figure()
CS = plt.contour(X, Y, Z)
plt.clabel(CS, inline=1, fontsize=10)
plt.title('Simplest default with labels')

Returning to the SymPy example, my_plot._backendprovides access to the shape and axes; What workarounds can I save or access the ContourSet?