- I don't typically program in Python unless I have to fix someone
- I've never used Matplotlib - this is my first attempt at
using it and, since it looked interesting, the ONLY reason I'm posting this answer.
Now a more robust answer: (Not that I enjoy doing homework for PhD candidates...)
Everything here was stolen - flat out stolen - from the matplotlib website (see Examples) and from Stack Overflow (matplotlib save fig image trim). All I did was copy/paste it and test it.
The resulting out.svg file can be opened directly in Inkscape. The image is a Group/Groups of smaller images. Click on any part of the image, then use Inkscape's 'Ungroup' option. You may have to ungroup a few times to be able to directly manipulate part of the image.
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
fig.colorbar(surf, shrink=0.5, aspect=5)
fig.savefig('out.svg', transparent=True, bbox_inches='tight', pad_inches=0)