Skip to content

No SVG/PDF export when useing latex package cmbrigth #4167

Closed

Description

@sorenwacker
import matplotlib as m
from matplotlib import pyplot as plt
m.rc('text.latex', preamble='\usepackage{cmbright}')
print m.__version__
'1.4.2'

def plotdemo():
    import numpy as np
    from matplotlib import pyplot as plt
    x=np.arange(0,10,0.001)
    y=np.sin(x)
    plt.suptitle('DEMO',x=0)
    plt.title("Sinus")
    plt.xlabel('x')
    plt.ylabel('sin(x)')
    plt.plot(x,y,label='Sinus(x)')
    plt.legend()
    plt.tight_layout()

plotdemo()
plt.savefig('test.svg')

IOError                                   Traceback (most recent call last)
<ipython-input-7-0ac8fb0b7f39> in <module>()
     19 
     20 plotdemo()
---> 21 plt.savefig('test.svg')

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.pyc in savefig(*args, **kwargs)
    575 def savefig(*args, **kwargs):
    576     fig = gcf()
--> 577     res = fig.savefig(*args, **kwargs)
    578     draw()   # need this if 'transparent=True' to reset colors
    579     return res

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in savefig(self, *args, **kwargs)
   1468             self.set_frameon(frameon)
   1469 
-> 1470         self.canvas.print_figure(*args, **kwargs)
   1471 
   1472         if frameon:

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2192                 orientation=orientation,
   2193                 bbox_inches_restore=_bbox_inches_restore,
-> 2194                 **kwargs)
   2195         finally:
   2196             if bbox_inches and restore_bbox:

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_svg.pyc in print_svg(self, filename, *args, **kwargs)
   1174         else:
   1175             raise ValueError("filename must be a path or a file-like object")
-> 1176         return self._print_svg(filename, svgwriter, fh_to_close, **kwargs)
   1177 
   1178     def print_svgz(self, filename, *args, **kwargs):

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_svg.pyc in _print_svg(self, filename, svgwriter, fh_to_close, **kwargs)
   1202                     bbox_inches_restore=_bbox_inches_restore)
   1203 
-> 1204             self.figure.draw(renderer)
   1205             renderer.finalize()
   1206         finally:

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)
   1077         dsu.sort(key=itemgetter(0))
   1078         for zorder, a, func, args in dsu:
-> 1079             func(*args)
   1080 
   1081         renderer.close_group('figure')

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2090 
   2091         for zorder, a in dsu:
-> 2092             a.draw(renderer)
   2093 
   2094         renderer.close_group('axes')

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in draw(self, renderer, *args, **kwargs)
   1117 
   1118         for tick in ticks_to_draw:
-> 1119             tick.draw(renderer)
   1120 
   1121         # scale up the axis label box to also find the neighbors, not

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in draw(self, renderer)
    247 
    248         if self.label1On:
--> 249             self.label1.draw(renderer)
    250         if self.label2On:
    251             self.label2.draw(renderer)

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in draw(self, renderer)
    579             if rcParams['text.usetex']:
    580                 renderer.draw_tex(gc, x, y, clean_line,
--> 581                                   self._fontproperties, angle, mtext=mtext)
    582             else:
    583                 renderer.draw_text(gc, x, y, clean_line,

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_svg.pyc in draw_tex(self, gc, x, y, s, prop, angle, ismath, mtext)
   1120 
   1121     def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
-> 1122         self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
   1123 
   1124     def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_svg.pyc in _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext)
    927             if ismath == "TeX":
    928                 _glyphs = text2path.get_glyphs_tex(prop, s, glyph_map=glyph_map,
--> 929                                                    return_new_glyphs_only=True)
    930             else:
    931                 _glyphs = text2path.get_glyphs_mathtext(prop, s, glyph_map=glyph_map,

/home/swacker/Programme/anaconda/lib/python2.7/site-packages/matplotlib/textpath.pyc in get_glyphs_tex(self, prop, s, glyph_map, return_new_glyphs_only)
    340 
    341             if font_and_encoding is None:
--> 342                 font = FT2Font(font_bunch.filename)
    343 
    344                 for charmap_name, charmap_code in [("ADOBE_CUSTOM",

IOError: [Errno 2] No such file or directory: u''

[tac edited to add markup]

Activity

  1. changed the title [-]No SVG export when useing latex package cmbrigth[/-] [+]No SVG/PDF export when useing latex package cmbrigth[/+] on Feb 25, 2015
  2. added this to the milestone on Feb 26, 2015
  3. tacaswell commented on Feb 26, 2015

    @tacaswell
    Member

    Can you try with 1.4.3?

  4. tacaswell commented on Feb 26, 2015

    @tacaswell
    Member

    It looks like it is choking on not being able to find a font file. What is cmbright?

  5. jkseppan commented on Jun 14, 2015

    @jkseppan
    Member

    Please remember that the preamble setting is not supported: http://matplotlib.org/users/usetex.html

    My guess as to the problem: the cmbright package doesn't include Type-1 fonts (see e.g. http://tex.stackexchange.com/questions/206735/math-font-pixellated-cmbright), and matplotlib's dviread.py doesn't support metafont.

  6. sorenwacker commented on Oct 28, 2015

    @sorenwacker
    Author

    @tacaswell
    It is also not working with 1.4.3.
    I use cmbright to change the fonttype of the x/y-ticks to sans-serif.
    When latex is activated the default is set to serif.
    But as jkseppan pointed out, maybe that is a feature that is just not supported.
    In that case you can close this issue.

  7. anntzer commented on Dec 15, 2017

    @anntzer
    Contributor

    Closed (by improving the error message) by #6428.

  8. modified the milestones: , on Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions