Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX broken for holoviews.Surface #1222

Closed
basnijholt opened this issue Mar 22, 2017 · 9 comments
Closed

LaTeX broken for holoviews.Surface #1222

basnijholt opened this issue Mar 22, 2017 · 9 comments
Assignees
Labels
tag: backend: mpl type: bug Something isn't correct or isn't working
Milestone

Comments

@basnijholt
Copy link
Contributor

Reproduce with:

import holoviews as hv
import numpy as np

hv.notebook_extension('matplotlib')
hv.plotting.mpl.MPLPlot.fig_rcparams['text.usetex'] = True

hv.Surface(np.random.rand(8, 8))
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
/opt/conda/envs/dev/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    305                 pass
    306             else:
--> 307                 return printer(obj)
    308             # Finally look for special method names
    309             method = get_real_method(obj, self.print_method)

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in pprint_display(obj)
    236     if not ip.display_formatter.formatters['text/plain'].pprint:
    237         return None
--> 238     return display(obj, raw=True)
    239 
    240 

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in display(obj, raw, **kwargs)
    218         html = grid_display(obj)
    219     elif isinstance(obj, (CompositeOverlay, ViewableElement)):
--> 220         html = element_display(obj)
    221     elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
    222         html = layout_display(obj)

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in wrapped(element)
    147             if sys.version_info[0] < 3:
    148                 raise (t, v, tb)
--> 149             raise v.with_traceback(tb)
    150     return wrapped
    151 

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in wrapped(element)
    114             html = fn(element,
    115                       max_frames=OutputMagic.options['max_frames'],
--> 116                       max_branches = OutputMagic.options['max_branches'])
    117 
    118             # Only want to add to the archive for one display hook...

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in element_display(element, max_frames, max_branches)
    164     if renderer.fig == 'pdf':
    165         renderer = renderer.instance(fig='png')
--> 166     return renderer.html(element, fmt=renderer.fig)
    167 
    168 

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/renderer.py in html(self, obj, fmt, css, comm, **kwargs)
    261         """
    262         plot, fmt =  self._validate(obj, fmt)
--> 263         figdata, _ = self(plot, fmt, **kwargs)
    264         if css is None: css = self.css
    265 

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/mpl/renderer.py in __call__(self, obj, fmt)
     99             data = plot()
    100         elif fmt in ['png', 'svg', 'pdf', 'html', 'json']:
--> 101             data = self._figure_data(plot, fmt, **({'dpi':self.dpi} if self.dpi else {}))
    102         else:
    103             if sys.version_info[0] == 3 and mpl.__version__[:-2] in ['1.2', '1.3']:

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/mpl/renderer.py in _figure_data(self, plot, fmt, bbox_inches, **kwargs)
    211 
    212         bytes_io = BytesIO()
--> 213         fig.canvas.print_figure(bytes_io, **kw)
    214         data = bytes_io.getvalue()
    215         if fmt == 'svg':

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2190                     orientation=orientation,
   2191                     dryrun=True,
-> 2192                     **kwargs)
   2193                 renderer = self.figure._cachedRenderer
   2194                 bbox_inches = self.figure.get_tightbbox(renderer)

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
    543 
    544     def print_png(self, filename_or_obj, *args, **kwargs):
--> 545         FigureCanvasAgg.draw(self)
    546         renderer = self.get_renderer()
    547         original_dpi = renderer.dpi

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw(self)
    462 
    463         try:
--> 464             self.figure.draw(self.renderer)
    465         finally:
    466             RendererAgg.lock.release()

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/figure.py in draw(self, renderer)
   1141 
   1142             mimage._draw_list_compositing_images(
-> 1143                 renderer, self, dsu, self.suppressComposite)
   1144 
   1145             renderer.close_group('figure')

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, dsu, suppress_composite)
    137     if not_composite or not has_images:
    138         for zorder, a in dsu:
--> 139             a.draw(renderer)
    140     else:
    141         # Composite any adjacent images together

/opt/conda/envs/dev/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py in draw(self, renderer)
    288             # Then axes
    289             for ax in axes:
--> 290                 ax.draw(renderer)
    291 
    292         # Then rest

/opt/conda/envs/dev/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axis3d.py in draw(self, renderer)
    452             tick.set_label1(label)
    453             tick.set_label2(label)
--> 454             tick.draw(renderer)
    455 
    456         renderer.close_group('axis3d')

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/axis.py in draw(self, renderer)
    262 
    263         if self.label1On:
--> 264             self.label1.draw(renderer)
    265         if self.label2On:
    266             self.label2.draw(renderer)

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/text.py in draw(self, renderer)
    796                     textrenderer.draw_tex(gc, x, y, clean_line,
    797                                           textobj._fontproperties, angle,
--> 798                                           mtext=mtext)
    799                 else:
    800                     textrenderer.draw_text(gc, x, y, clean_line,

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw_tex(self, gc, x, y, s, prop, angle, ismath, mtext)
    252         texmanager = self.get_texmanager()
    253 
--> 254         Z = texmanager.get_grey(s, size, self.dpi)
    255         Z = np.array(Z * 255.0, np.uint8)
    256 

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/texmanager.py in get_grey(self, tex, fontsize, dpi)
    582 
    583         if alpha is None:
--> 584             pngfile = self.make_png(tex, fontsize, dpi)
    585             X = read_png(os.path.join(self.texcache, pngfile))
    586 

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/texmanager.py in make_png(self, tex, fontsize, dpi)
    505         # see get_rgba for a discussion of the background
    506         if DEBUG or not os.path.exists(pngfile):
--> 507             dvifile = self.make_dvi(tex, fontsize)
    508             outfile = basefile + '.output'
    509             command = self._get_shell_cmd(

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/texmanager.py in make_dvi(self, tex, fontsize)
    397 
    398         if DEBUG or not os.path.exists(dvifile):
--> 399             texfile = self.make_tex(tex, fontsize)
    400             outfile = basefile + '.output'
    401             command = self._get_shell_cmd(

/opt/conda/envs/dev/lib/python3.6/site-packages/matplotlib/texmanager.py in make_tex(self, tex, fontsize)
    312             else:
    313                 try:
--> 314                     fh.write(s.encode('ascii'))
    315                 except UnicodeEncodeError as err:
    316                     mpl.verbose.report("You are using unicode and latex, but "

UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in position 229: ordinal not in range(128)
@jlstevens
Copy link
Contributor

Certainly worth investigating before 1.7!

@jlstevens jlstevens added this to the v1.7.0 milestone Mar 22, 2017
@basnijholt
Copy link
Contributor Author

That would be great 👍 because it breaks a lot of plots at https://topocondmat.org/

@philippjfr
Copy link
Member

Any idea when this might have happened? Is it since upgrading to matplotlib 2.0? Any rough estimate would be helpful since it limits the amount of bisecting I have to do.

@basnijholt
Copy link
Contributor Author

Thanks for the quick fix!

@philippjfr
Copy link
Member

@basnijholt No worries, would you mind checking that the rcParams are now behaving as you'd expect?

@csgorham
Copy link

@basnijholt This error is breaking the codes for topocondmat.org .. any chance you can help me to fix it? How did you fix it? Thanks!

@basnijholt
Copy link
Contributor Author

Hi @csgorham, I have fixed most errors in this branch. So if you checkout new-versions then you should be fine.

However, I still have some issues with the HoloViews's JavaScript, so that's why it's not in master yet.

@philippjfr
Copy link
Member

@basnijholt Have you guys tried upgrading to HoloViews 1.13.0 dev releases yet? I'm hoping to get that release out by tomorrow and it no longer uses any of the old Javascript.

@csgorham
Copy link

Thanks! Just updated. module 'holoviews.plotting' has no attribute 'widgets'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: backend: mpl type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

4 participants