What other libraries do you need to install matplotlib to write tiff files to?

I use matplotlib (version 1.4) to create the images I need in .tiff format. I draw on an IPython laptop (version 3.2) with the backend %matplotlib inline . I usually use Anaconda distribution and can easily save matplotlib data in .tiff. However, I am trying to build a minimal set of dependencies that I can use as a conda environment. I am currently using:

  • Python = 2.7
  • Ipython laptop
  • flask
  • NumPy = 1.9
  • SciPy = 0.16
  • pandas = 0.16
  • numexpr = 2.3
  • statsmodels = 0.6
  • Siborn = 0.6
  • Matplotlib = 1.4
  • scikit study = 0.16
  • scikit images = 0.10
  • MayaVi = 4.3

When I run my code in this environment, I get an error message:

 --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-14-3d911065b472> in <module>() 56 f.text(.01, .38, "B", size=14) 57 ---> 58 savefig(f, "switch_control") <ipython-input-6-4016f8a0f32d> in savefig(fig, name) ----> 4 fig.savefig("figures/{}.tiff".format(name), dpi=300) /Users/mwaskom/anaconda/envs/punch/lib/python2.7/site-packages/matplotlib/figure.pyc in savefig(self, *args, **kwargs) 1474 self.set_frameon(frameon) 1475 -> 1476 self.canvas.print_figure(*args, **kwargs) 1477 1478 if frameon: /Users/mwaskom/anaconda/envs/punch/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs) 2117 2118 # get canvas object and print method for format -> 2119 canvas = self._get_output_canvas(format) 2120 print_method = getattr(canvas, 'print_%s' % format) 2121 /Users/mwaskom/anaconda/envs/punch/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in _get_output_canvas(self, format) 2059 raise ValueError('Format "%s" is not supported.\n' 2060 'Supported formats: ' -> 2061 '%s.' % (format, ', '.join(formats))) 2062 2063 def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w', ValueError: Format "tiff" is not supported. Supported formats: eps, pdf, pgf, png, ps, raw, rgba, svg, svgz. 

I assume that the .tiff support in matplotlib depends on one of the other libraries included in the full Anaconda distribution, however it is not clear from the search around which one may be.

Interestingly, it works great if I just open the IPython terminal and draw using the default backend (Mac OSX for me). Thus, the problem is, in particular, with the built-in backend for the IPython laptop, although, as mentioned above, this works great when using the full anaconda distribution.

In both cases, when I do

 import matplotlib as mpl mpl.get_backend() 

shows

 'module://IPython.kernel.zmq.pylab.backend_inline' 

What else do I need to install to get support for .tiff files?

+6
source share
1 answer

Apparently, installing PIL through conda allows conda to support .tiff support for Agg -based-backend in matplotlib.

+3
source

All Articles