Ask Your Question

sbott's profile - activity

2015-03-10 00:35:57 +0100 received badge  Famous Question (source)
2012-12-21 15:54:02 +0100 received badge  Notable Question (source)
2012-07-08 12:18:47 +0100 received badge  Popular Question (source)
2012-01-05 17:57:40 +0100 commented answer no more inline matplotlib plots in sage notebook

Thanks for the comment but I don't believe this is related with imagemagick. On other computers sage installations (same version 4.6.2 and no imagemagick) I never experienced trouble with inline plots in the notebook. savefig('.') savefig('name') savefig('name.png') all generated a graph in png format displayed in the notebook browser. I'm not aware of any settings change on my main computer, but now savefig('.') savefig('name') generate a link which opens the graph as pdf in a new window. Sincerely

2012-01-05 08:05:08 +0100 received badge  Student (source)
2012-01-05 05:23:41 +0100 asked a question no more inline matplotlib plots in sage notebook


I can't get any matplotplib/pylab plots inline in a notebook. Plots now are created as pdf files that open in another window.

For example, the code below used to create the plot in a new box after the instruction plt.savefig('.')

import numpy as np
import pylab as plt
x = np.arange(-2 * np.pi, 2 * np.pi,0.1) 
plt.plot(x, np.sin(x), label='sin(x)')  

now it returns a link '.pdf' to a pdf file.



returns the following traceback:

Traceback (most recent call last):    
  File "", line 1, in <module>

  File "/private/var/folders/k7/k7XHz3-82RazCk+kNOj55U+++TM/-Tmp-/tmpjD4zHK/", line 14, in <module>
    exec compile(u"plt.savefig('a.png')" + '\n', '', 'single')
  File "", line 1, in <module>

  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/matplotlib/", line 363, in savefig
    return fig.savefig(*args, **kwargs)
  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/matplotlib/", line 1084, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/matplotlib/", line 1853, in print_figure
    print_method = self._get_print_method(format)
  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/matplotlib/", line 1793, in _get_print_method
    '%s.' % (format, ', '.join(formats)))
ValueError: Format "png" is not supported.
Supported formats: pdf.

I don't know what settings changes I may have done, and couldn't find any documented help format settings in sage for matplotlib plots. Interestingly I used to experience before the impossibility to export sage generated plots in pdf... It would be nice to have a better control on these settings.

Thank you for any help