I'm looking to save my Sage figures with matplotlib's usetex option, so that I can match the fonts to my document's fonts. The following code works to do this if I switch the filename extension in the last line to png, but for some reason when I try to save a pdf instead, the kernel dies. I would be grateful for any suggestions.
from matplotlib import rc
rc('text',usetex=True)
rc('font',serif='Palatino')
p = plot(sin(x),x,0,2*pi,axes_labels=['$x$','$\sin x$'])
save(p,filename="tmp.pdf")