# Buggy code
def __call__(self, obj, fmt="auto"):
    """
    Render the supplied HoloViews component or MPLPlot instance
    using matplotlib.
    """
    plot, fmt = self._validate(obj, fmt)
    if plot is None:
        return

    if isinstance(plot, tuple(self.widgets.values())):
        data = plot()
    elif fmt in ["png", "svg", "pdf", "html", "json"]:
        data = self._figure_data(plot, fmt, **({"dpi": self.dpi} if self.dpi else {}))
    else:
        if sys.version_info[0] == 3 and mpl.__version__[:-2] in ["1.2", "1.3"]:
            raise Exception(
                "<b>Python 3 matplotlib animation support broken &lt;= 1.3</b>"
            )
        anim = plot.anim(fps=self.fps)
        data = self._anim_data(anim, fmt)

    data = self._apply_post_render_hooks(data, obj, fmt)
    return data, {"file-ext": fmt, "mime_type": MIME_TYPES[fmt]}


# Traceback (UnicodeEncodeError)
---------------------------------------------------------------------------
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)

# Fixed code
def __call__(self, obj, fmt="auto"):
    """
    Render the supplied HoloViews component or MPLPlot instance
    using matplotlib.
    """
    plot, fmt = self._validate(obj, fmt)
    if plot is None:
        return

    if isinstance(plot, tuple(self.widgets.values())):
        data = plot()
    elif fmt in ["png", "svg", "pdf", "html", "json"]:
        with mpl.rc_context(rc=plot.fig_rcparams):
            data = self._figure_data(
                plot, fmt, **({"dpi": self.dpi} if self.dpi else {})
            )
    else:
        if sys.version_info[0] == 3 and mpl.__version__[:-2] in ["1.2", "1.3"]:
            raise Exception(
                "<b>Python 3 matplotlib animation support broken &lt;= 1.3</b>"
            )
        with mpl.rc_context(rc=plot.fig_rcparams):
            anim = plot.anim(fps=self.fps)
        data = self._anim_data(anim, fmt)

    data = self._apply_post_render_hooks(data, obj, fmt)
    return data, {"file-ext": fmt, "mime_type": MIME_TYPES[fmt]}