# Buggy code
def _get_colormapper(
    self,
    eldim,
    element,
    ranges,
    style,
    factors=None,
    colors=None,
    group=None,
    name="color_mapper",
):
    # The initial colormapper instance is cached the first time
    # and then only updated
    if eldim is None and colors is None:
        return None
    dim_name = dim_range_key(eldim)

    # Attempt to find matching colormapper on the adjoined plot
    if self.adjoined:
        cmapper_name = dim_name + name
        cmappers = self.adjoined.traverse(
            lambda x: (
                x.handles.get("color_dim"),
                x.handles.get(name, x.handles.get(cmapper_name)),
            )
        )
        cmappers = [cmap for cdim, cmap in cmappers if cdim == eldim]
        if cmappers:
            cmapper = cmappers[0]
            self.handles["color_mapper"] = cmapper
            return cmapper
        else:
            return None

    ncolors = None if factors is None else len(factors)
    if eldim:
        # check if there's an actual value (not np.nan)
        if all(util.isfinite(cl) for cl in self.clim):
            low, high = self.clim
        elif dim_name in ranges:
            low, high = ranges[dim_name]["combined"]
            dlow, dhigh = ranges[dim_name]["data"]
            if (
                util.is_int(low, int_like=True)
                and util.is_int(high, int_like=True)
                and util.is_int(dlow)
                and util.is_int(dhigh)
            ):
                low, high = int(low), int(high)
        elif isinstance(eldim, dim):
            low, high = np.nan, np.nan
        else:
            low, high = element.range(eldim.name)
        if self.symmetric:
            sym_max = max(abs(low), high)
            low, high = -sym_max, sym_max
        low = self.clim[0] if util.isfinite(self.clim[0]) else low
        high = self.clim[1] if util.isfinite(self.clim[1]) else high
    else:
        low, high = None, None

    prefix = "" if group is None else group + "_"
    cmap = colors or style.get(prefix + "cmap", style.get("cmap", "viridis"))
    nan_colors = {k: rgba_tuple(v) for k, v in self.clipping_colors.items()}
    if isinstance(cmap, dict):
        if factors is None:
            factors = list(cmap)
        palette = [
            cmap.get(f, nan_colors.get("NaN", self._default_nan)) for f in factors
        ]
        if isinstance(eldim, dim):
            if eldim.dimension in element:
                formatter = element.get_dimension(eldim.dimension).pprint_value
            else:
                formatter = str
        else:
            formatter = eldim.pprint_value
        factors = [formatter(f) for f in factors]
    else:
        categorical = ncolors is not None
        if isinstance(self.color_levels, int):
            ncolors = self.color_levels
        elif isinstance(self.color_levels, list):
            ncolors = len(self.color_levels) - 1
            if isinstance(cmap, list) and len(cmap) != ncolors:
                raise ValueError(
                    "The number of colors in the colormap "
                    "must match the intervals defined in the "
                    "color_levels, expected %d colors found %d." % (ncolors, len(cmap))
                )
        palette = process_cmap(cmap, ncolors, categorical=categorical)
        if isinstance(self.color_levels, list):
            palette, (low, high) = color_intervals(
                palette, self.color_levels, clip=(low, high)
            )
    colormapper, opts = self._get_cmapper_opts(low, high, factors, nan_colors)

    cmapper = self.handles.get(name)
    if cmapper is not None:
        if cmapper.palette != palette:
            cmapper.palette = palette
        opts = {k: opt for k, opt in opts.items() if getattr(cmapper, k) != opt}
        if opts:
            cmapper.update(**opts)
    else:
        cmapper = colormapper(palette=palette, **opts)
        self.handles[name] = cmapper
        self.handles["color_dim"] = eldim
    return cmapper


# Traceback (KeyError)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/miniconda3/envs/py37/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
968
969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
971             return None
972         else:

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/core/dimension.py in _repr_mimebundle_(self, include, exclude)
1302         combined and returned.
1303         """
-> 1304         return Store.render(self)
1305
1306

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/core/options.py in render(cls, obj)
1393         data, metadata = {}, {}
1394         for hook in hooks:
-> 1395             ret = hook(obj)
1396             if ret is None:
1397                 continue

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/ipython/display_hooks.py in pprint_display(obj)
280     if not ip.display_formatter.formatters['text/plain'].pprint:
281         return None
--> 282     return display(obj, raw_output=True)
283
284

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/ipython/display_hooks.py in display(obj, raw_output, **kwargs)
250     elif isinstance(obj, (CompositeOverlay, ViewableElement)):
251         with option_state(obj):
--> 252             output = element_display(obj)
253     elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
254         with option_state(obj):

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/ipython/display_hooks.py in wrapped(element)
144         try:
145             max_frames = OutputSettings.options['max_frames']
--> 146             mimebundle = fn(element, max_frames=max_frames)
147             if mimebundle is None:
148                 return {}, {}

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/ipython/display_hooks.py in element_display(element, max_frames)
190         return None
191
--> 192     return render(element)
193
194

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
66         renderer = renderer.instance(fig='png')
67
---> 68     return renderer.components(obj, **kwargs)
69
70

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/plotting/renderer.py in components(self, obj, fmt, comm, **kwargs)
353             plot = obj
354         else:
--> 355             plot, fmt = self._validate(obj, fmt)
356
357         data, metadata = {}, {}

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/plotting/renderer.py in _validate(self, obj, fmt, **kwargs)
278                                  renderer=self)
279         else:
--> 280             plot = self.get_plot(obj, renderer=self, **kwargs)
281
282         all_formats = set(fig_formats + holomap_formats)

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs)
221             init_key = tuple(v if d is None else d for v, d in
222                              zip(plot.keys[0], defaults))
--> 223             plot.update(init_key)
224         else:
225             plot = obj

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/plotting/mpl/plot.py in update(self, key)
257     def update(self, key):
258         if len(self) == 1 and ((key == 0) or (key == self.keys[0])) and not self.drawn:
--> 259             return self.initialize_plot()
260         return self.__getitem__(key)
261

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/plotting/mpl/plot.py in wrapper(self, *args, **kwargs)
53     def wrapper(self, *args, **kwargs):
54         with _rc_context(self.fig_rcparams):
---> 55             return f(self, *args, **kwargs)
56     return wrapper
57

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/plotting/mpl/element.py in initialize_plot(self, ranges)
508             style['label'] = element.label
509
--> 510         plot_data, plot_kwargs, axis_kwargs = self.get_data(element, ranges, style)
511
512         with abbreviated_exception():

~/miniconda3/envs/py37/lib/python3.7/site-packages/holoviews/plotting/mpl/path.py in get_data(self, element, ranges, style)
66         if not (self.color_index or style_mapping):
67             if cdim:
---> 68                 style['array'] = style.pop('c')
69                 style['clim'] = style.pop('vmin', None), style.pop('vmax', None)
70             return (paths,), style, {'dimensions': dims}

KeyError: 'c'

# Fixed code
def _get_colormapper(
    self,
    eldim,
    element,
    ranges,
    style,
    factors=None,
    colors=None,
    group=None,
    name="color_mapper",
):
    # The initial colormapper instance is cached the first time
    # and then only updated
    if eldim is None and colors is None:
        return None
    dim_name = dim_range_key(eldim)

    # Attempt to find matching colormapper on the adjoined plot
    if self.adjoined:
        cmappers = self.adjoined.traverse(
            lambda x: (
                x.handles.get("color_dim"),
                x.handles.get(name),
                [v for v in x.handles.values() if isinstance(v, ColorMapper)],
            )
        )
        cmappers = [
            (cmap, mappers) for cdim, cmap, mappers in cmappers if cdim == eldim
        ]
        if cmappers:
            cmapper, mappers = cmappers[0]
            cmapper = cmapper if cmapper else mappers[0]
            self.handles["color_mapper"] = cmapper
            return cmapper
        else:
            return None

    ncolors = None if factors is None else len(factors)
    if eldim:
        # check if there's an actual value (not np.nan)
        if all(util.isfinite(cl) for cl in self.clim):
            low, high = self.clim
        elif dim_name in ranges:
            low, high = ranges[dim_name]["combined"]
            dlow, dhigh = ranges[dim_name]["data"]
            if (
                util.is_int(low, int_like=True)
                and util.is_int(high, int_like=True)
                and util.is_int(dlow)
                and util.is_int(dhigh)
            ):
                low, high = int(low), int(high)
        elif isinstance(eldim, dim):
            low, high = np.nan, np.nan
        else:
            low, high = element.range(eldim.name)
        if self.symmetric:
            sym_max = max(abs(low), high)
            low, high = -sym_max, sym_max
        low = self.clim[0] if util.isfinite(self.clim[0]) else low
        high = self.clim[1] if util.isfinite(self.clim[1]) else high
    else:
        low, high = None, None

    prefix = "" if group is None else group + "_"
    cmap = colors or style.get(prefix + "cmap", style.get("cmap", "viridis"))
    nan_colors = {k: rgba_tuple(v) for k, v in self.clipping_colors.items()}
    if isinstance(cmap, dict):
        if factors is None:
            factors = list(cmap)
        palette = [
            cmap.get(f, nan_colors.get("NaN", self._default_nan)) for f in factors
        ]
        if isinstance(eldim, dim):
            if eldim.dimension in element:
                formatter = element.get_dimension(eldim.dimension).pprint_value
            else:
                formatter = str
        else:
            formatter = eldim.pprint_value
        factors = [formatter(f) for f in factors]
    else:
        categorical = ncolors is not None
        if isinstance(self.color_levels, int):
            ncolors = self.color_levels
        elif isinstance(self.color_levels, list):
            ncolors = len(self.color_levels) - 1
            if isinstance(cmap, list) and len(cmap) != ncolors:
                raise ValueError(
                    "The number of colors in the colormap "
                    "must match the intervals defined in the "
                    "color_levels, expected %d colors found %d." % (ncolors, len(cmap))
                )
        palette = process_cmap(cmap, ncolors, categorical=categorical)
        if isinstance(self.color_levels, list):
            palette, (low, high) = color_intervals(
                palette, self.color_levels, clip=(low, high)
            )
    colormapper, opts = self._get_cmapper_opts(low, high, factors, nan_colors)

    cmapper = self.handles.get(name)
    if cmapper is not None:
        if cmapper.palette != palette:
            cmapper.palette = palette
        opts = {k: opt for k, opt in opts.items() if getattr(cmapper, k) != opt}
        if opts:
            cmapper.update(**opts)
    else:
        cmapper = colormapper(palette=palette, **opts)
        self.handles[name] = cmapper
        self.handles["color_dim"] = eldim
    return cmapper