# Buggy code
def mpl_rc_context(f):
    """
    Applies matplotlib rc params while when method is called.
    """

    def wrapper(self, *args, **kwargs):
        with mpl.rc_context(rc=self.fig_rcparams):
            return f(self, *args, **kwargs)

    return wrapper


# 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)
220         html = element_display(obj)
221     elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
--> 222         html = layout_display(obj)
223     elif isinstance(obj, (HoloMap, DynamicMap)):
224         html = map_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 layout_display(layout, max_frames, max_branches)
194                 return '<tt>'+ sanitize_HTML(layout) + '</tt>'
195
--> 196     return render(layout)
197
198

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
55     if renderer.fig == 'pdf':
56         renderer = renderer.instance(fig='png')
---> 57     return renderer.html(obj, **kwargs)
58
59

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

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/renderer.py in _validate(self, obj, fmt)
196         if isinstance(obj, tuple(self.widgets.values())):
197             return obj, 'html'
--> 198         plot = self.get_plot(obj, renderer=self)
199
200         fig_formats = self.mode_formats['fig'][self.mode]

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, renderer)
183             plot = self_or_cls.plotting_class(obj)(obj, renderer=renderer,
184                                                    **plot_opts)
--> 185             plot.update(0)
186         else:
187             plot = obj

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in update(self, key)
212         if len(self) == 1 and key == 0 and not self.drawn:
213             return self.initialize_plot()
--> 214         return self.__getitem__(key)
215
216

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/plot.py in __getitem__(self, frame)
214         if not self.dynamic == 'open' and isinstance(frame, int) and frame > len(self):
215             self.warning("Showing last frame available: %d" % len(self))
--> 216         if not self.drawn: self.handles['fig'] = self.initialize_plot()
217         if not self.dynamic == 'open' and not isinstance(frame, tuple):
218             frame = self.keys[frame]

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in initialize_plot(self)
1041                                 title_obj, extra_artists,
1042                                 vspace=self.vspace*self.fig_scale,
-> 1043                                 hspace=self.hspace*self.fig_scale)
1044             colorbars = self.traverse(specs=[lambda x: hasattr(x, 'colorbar')])
1045             for cbar_plot in colorbars:

/opt/conda/envs/dev/lib/python3.6/site-packages/holoviews/plotting/mpl/util.py in fix_aspect(fig, nrows, ncols, title, extra_artists, vspace, hspace)
100     the size of the figure to match the aspect.
101     """
--> 102     fig.canvas.draw()
103     w, h = fig.get_size_inches()
104

/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/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/axes/_base.py in draw(self, renderer, inframe)
2407             renderer.stop_rasterizing()
2408
-> 2409         mimage._draw_list_compositing_images(renderer, self, dsu)
2410
2411         renderer.close_group('axes')

/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/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, *args, **kwargs)
1139
1140         for tick in ticks_to_draw:
-> 1141             tick.draw(renderer)
1142
1143         # scale up the axis label box to also find the neighbors, not

/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)

Out[1]:
:Layout
.HoloMap.I  :HoloMap   [Default]
:VLine   [x,y]
.HoloMap.II :HoloMap   [Default]
:Path   [x,y]

# Fixed code
def mpl_rc_context(f):
    """
    Decorator for MPLPlot methods applying the matplotlib rc params
    in the plots fig_rcparams while when method is called.
    """

    def wrapper(self, *args, **kwargs):
        with _rc_context(self.fig_rcparams):
            return f(self, *args, **kwargs)

    return wrapper