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

Adding label to contour * image crashes #3903

Closed
ahuang11 opened this issue Aug 15, 2019 · 3 comments · Fixed by #4031
Closed

Adding label to contour * image crashes #3903

ahuang11 opened this issue Aug 15, 2019 · 3 comments · Fixed by #4031
Labels
tag: backend: mpl type: bug Something isn't correct or isn't working
Milestone

Comments

@ahuang11
Copy link
Collaborator

ahuang11 commented Aug 15, 2019

This works

import hvplot.xarray
import xarray as xr
import holoviews as hv
hv.extension()

ds = xr.tutorial.open_dataset('air_temperature').isel(time=0)
ds.hvplot('lon', 'lat') * ds.hvplot.contour('lon', 'lat').opts(colorbar=False)

This crashes:

import hvplot.xarray
import xarray as xr
import holoviews as hv
hv.extension()

ds = xr.tutorial.open_dataset('air_temperature').isel(time=0)
ds.hvplot('lon', 'lat', label='air') * ds.hvplot.contour('lon', 'lat').opts(colorbar=False)

Error below in comments

@jbednar jbednar closed this as completed Aug 15, 2019
@jbednar
Copy link
Member

jbednar commented Aug 15, 2019

Can you please add the "crash" error messages?

@jbednar jbednar reopened this Aug 15, 2019
@ahuang11
Copy link
Collaborator Author

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/anaconda3/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:

~/anaconda3/lib/python3.7/site-packages/holoviews/core/dimension.py in _repr_mimebundle_(self, include, exclude)
   1292         combined and returned.
   1293         """
-> 1294         return Store.render(self)
   1295 
   1296 

~/anaconda3/lib/python3.7/site-packages/holoviews/core/options.py in render(cls, obj)
   1364         data, metadata = {}, {}
   1365         for hook in hooks:
-> 1366             ret = hook(obj)
   1367             if ret is None:
   1368                 continue

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

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

~/anaconda3/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 {}, {}

~/anaconda3/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 

~/anaconda3/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 

~/anaconda3/lib/python3.7/site-packages/holoviews/plotting/renderer.py in components(self, obj, fmt, comm, **kwargs)
    319             plot = obj
    320         else:
--> 321             plot, fmt = self._validate(obj, fmt)
    322 
    323         data, metadata = {}, {}

~/anaconda3/lib/python3.7/site-packages/holoviews/plotting/renderer.py in _validate(self, obj, fmt, **kwargs)
    218         if isinstance(obj, tuple(self.widgets.values())):
    219             return obj, 'html'
--> 220         plot = self.get_plot(obj, renderer=self, **kwargs)
    221 
    222         fig_formats = self.mode_formats['fig'][self.mode]

~/anaconda3/lib/python3.7/site-packages/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, renderer, **kwargs)
    205             init_key = tuple(v if d is None else d for v, d in
    206                              zip(plot.keys[0], defaults))
--> 207             plot.update(init_key)
    208         else:
    209             plot = obj

~/anaconda3/lib/python3.7/site-packages/holoviews/plotting/mpl/plot.py in update(self, key)
    247     def update(self, key):
    248         if len(self) == 1 and ((key == 0) or (key == self.keys[0])) and not self.drawn:
--> 249             return self.initialize_plot()
    250         return self.__getitem__(key)
    251 

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

~/anaconda3/lib/python3.7/site-packages/holoviews/plotting/mpl/element.py in initialize_plot(self, ranges)
   1067 
   1068         if self.show_legend and element is not None:
-> 1069             self._adjust_legend(element, axis)
   1070 
   1071         return self._finalize_axis(key, element=element, ranges=ranges,

~/anaconda3/lib/python3.7/site-packages/holoviews/plotting/mpl/element.py in _adjust_legend(self, overlay, axis)
   1039             leg = axis.legend(list(data.keys()), list(data.values()),
   1040                               title=title, scatterpoints=1,
-> 1041                               **dict(leg_spec, **self._fontsize('legend')))
   1042             title_fontsize = self._fontsize('legend_title')
   1043             if title_fontsize:

~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in legend(self, *args, **kwargs)
    421         if len(extra_args):
    422             raise TypeError('legend only accepts two non-keyword arguments')
--> 423         self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
    424         self.legend_._remove_method = self._remove_legend
    425         return self.legend_

~/anaconda3/lib/python3.7/site-packages/matplotlib/legend.py in __init__(self, parent, handles, labels, loc, numpoints, markerscale, markerfirst, scatterpoints, scatteryoffsets, prop, fontsize, borderpad, labelspacing, handlelength, handleheight, handletextpad, borderaxespad, columnspacing, ncol, mode, fancybox, shadow, title, title_fontsize, framealpha, edgecolor, facecolor, bbox_to_anchor, bbox_transform, frameon, handler_map)
    554 
    555         # init with null renderer
--> 556         self._init_legend_box(handles, labels, markerfirst)
    557 
    558         # If shadow is activated use framealpha if not

~/anaconda3/lib/python3.7/site-packages/matplotlib/legend.py in _init_legend_box(self, handles, labels, markerfirst)
    813                 # original artist/handle.
    814                 handle_list.append(handler.legend_artist(self, orig_handle,
--> 815                                                          fontsize, handlebox))
    816                 handles_and_labels.append((handlebox, textbox))
    817 

~/anaconda3/lib/python3.7/site-packages/matplotlib/legend_handler.py in legend_artist(self, legend, orig_handle, fontsize, handlebox)
    113         artists = self.create_artists(legend, orig_handle,
    114                                       xdescent, ydescent, width, height,
--> 115                                       fontsize, handlebox.get_transform())
    116 
    117         # create_artists will return a list of artists.

~/anaconda3/lib/python3.7/site-packages/matplotlib/legend_handler.py in create_artists(self, legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)
    677         for handle1 in orig_handle:
    678             handler = legend.get_legend_handler(handler_map, handle1)
--> 679             _a_list = handler.create_artists(
    680                 legend, handle1,
    681                 next(xds_cycle), ydescent, width, height, fontsize, trans)

AttributeError: 'NoneType' object has no attribute 'create_artists'

@philippjfr philippjfr added type: bug Something isn't correct or isn't working tag: backend: mpl labels Aug 15, 2019
@philippjfr philippjfr added this to the v1.12.x milestone Sep 22, 2019
@philippjfr philippjfr modified the milestones: v1.12.x, v1.12.6 Oct 3, 2019
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tag: backend: mpl type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants