Kernel dies with matplotlib usetex and PDF

asked 9 years ago

sswatson gravatar image

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")

Preview: (hide)

Comments

It works for me (Sage 6.10.rc1 complied on Debian jessie 64bit, run from the command line). Could you please give us some informations so that someone can try to reproduce your problem:

  • which version of Sage did you use ?
  • which OS ?
  • did you install Sage from the binaries, and which ones ?
  • did you compile Sage ?
  • which notebook did you use (Sage notebook or jupyter notebook) ?
  • did you use the command line ?
  • which error message did you get ?
  • ... ?
tmonteil gravatar imagetmonteil ( 9 years ago )

Thanks for the reply! It's good to know this problem is not universal. I'm using Sage 6.8, installed on OS X (10.10.5) using binaries (not sure which ones -- I went to the downloads page and did what seemed natural; not sure if that helps). I was using Jupyter notebook, but I just checked that the error also occurs in the Sage notebook. I get no error message in Jupyter (kernel just dies), but in the Sage notebook I get a generic 'Unhandled SIGABRT' message.

sswatson gravatar imagesswatson ( 9 years ago )

I've tried with the same version of Sage as yours (6.8) in a Jupyter notebook under Ubuntu 14.04: it works fine. So maybe there is a problem with your Sage install. Could you install a more recent version (i.e. Sage 6.9) and try again ?

eric_g gravatar imageeric_g ( 9 years ago )

OK, I upgraded to version 6.9 and everything works fine. Thanks!

sswatson gravatar imagesswatson ( 9 years ago )