# Revision history [back]

It seems not directly available within Sage but you can use matplotlib which is distributed with Sage. I found examples in the references of matplotlib that seems related to what you are looking for. You can adapt them for Sage:

• in the notebook by replacing the last line plt.show() with plt.savefig('my_fig.png')
• in the console by replacing the last line plt.show() with plt.savefig('my_fig.png') and then viewing it with your prefered image viewer (it was mentioned there that the show method for matplotlib is broken)

The following works for me

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contourf(X, Y, Z, cmap=cm.coolwarm)
ax.clabel(cset, fontsize=9, inline=1)

plt.savefig('contour_plot.png')