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

Add new annotations, HSpan, VSpan #4000

Merged
merged 5 commits into from
Oct 2, 2019
Merged

Add new annotations, HSpan, VSpan #4000

merged 5 commits into from
Oct 2, 2019

Conversation

ahuang11
Copy link
Collaborator

@ahuang11 ahuang11 commented Sep 27, 2019

#3996
Got it mostly working for bokeh, partially for matplotlib, and not touched for plotly. I need help resolving the warnings/errors.

  • bokeh center parameter
  • matplotlib datetime
  • plotly implementation
  • unit tests

Bokeh: no idea why it says I'm setting center=True; I didn't do that anywhere. I have a feeling annotation automatically passes that, but I can't find it.
image
image

Matplotlib: datetimes don't work, I don't know why it keeps adding 1.0 to the range
image

[numpy.datetime64('2017-05-01T00:00:00.000000000'), numpy.datetime64('2017-05-01T00:00:00.000000000'), 1.0]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/anaconda3/lib/python3.6/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:

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/dimension.py in _repr_mimebundle_(self, include, exclude)
   1290         combined and returned.
   1291         """
-> 1292         return Store.render(self)
   1293 
   1294 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/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

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/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 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/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):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/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 {}, {}

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/ipython/display_hooks.py in element_display(element, max_frames)
    190         return None
    191 
--> 192     return render(element)
    193 
    194 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
     66         renderer = renderer.instance(fig='png')
     67 
---> 68     return renderer.components(obj, **kwargs)
     69 
     70 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/renderer.py in components(self, obj, fmt, comm, **kwargs)
    351             plot = obj
    352         else:
--> 353             plot, fmt = self._validate(obj, fmt)
    354 
    355         data, metadata = {}, {}

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/renderer.py in _validate(self, obj, fmt, **kwargs)
    276             plot, fmt = HoloViewsPane(obj, center=True, backend=self.backend, renderer=self), fmt
    277         else:
--> 278             plot = self.get_plot(obj, renderer=self, **kwargs)
    279 
    280         all_formats = set(fig_formats + holomap_formats)

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs)
    220             init_key = tuple(v if d is None else d for v, d in
    221                              zip(plot.keys[0], defaults))
--> 222             plot.update(init_key)
    223         else:
    224             plot = obj

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/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 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/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 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/mpl/element.py in initialize_plot(self, ranges)
   1098 
   1099         return self._finalize_axis(key, element=element, ranges=ranges,
-> 1100                                    title=self._format_title(key))
   1101 
   1102 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/mpl/element.py in _finalize_axis(self, key, element, title, dimensions, ranges, xticks, yticks, zticks, xlabel, ylabel, zlabel)
    181 
    182                 # Set axes limits
--> 183                 self._set_axis_limits(axis, element, subplots, ranges)
    184 
    185             # Apply aspects

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/mpl/element.py in _set_axis_limits(self, axis, view, subplots, ranges)
    319         """
    320         # Extents
--> 321         extents = self.get_extents(view, ranges)
    322         if not extents or self.overlaid:
    323             axis.autoscale_view(scalex=True, scaley=True)

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/plot.py in get_extents(self, overlay, ranges, range_type)
   1538         subplot_extents = self._get_subplot_extents(overlay, ranges, range_type)
   1539         zrange = self.projection == '3d'
-> 1540         extents = {k: util.max_extents(rs, zrange) for k, rs in subplot_extents.items()}
   1541         if range_type != 'combined':
   1542             return extents[range_type]

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/plot.py in <dictcomp>(.0)
   1538         subplot_extents = self._get_subplot_extents(overlay, ranges, range_type)
   1539         zrange = self.projection == '3d'
-> 1540         extents = {k: util.max_extents(rs, zrange) for k, rs in subplot_extents.items()}
   1541         if range_type != 'combined':
   1542             return extents[range_type]

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/util.py in max_extents(extents, zrange)
   1039             if lower and isinstance(lower[0], datetime_types):
   1040                 extents[lidx] = np.min(lower)
-> 1041             elif any(isinstance(l, basestring) for l in lower):
   1042                 extents[lidx] = np.sort(lower)[0]
   1043             elif lower:

~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in amin(a, axis, out, keepdims, initial)
   2616     """
   2617     return _wrapreduction(a, np.minimum, 'min', axis, None, out, keepdims=keepdims,
-> 2618                           initial=initial)
   2619 
   2620 

~/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
     84                 return reduction(axis=axis, out=out, **passkwargs)
     85 
---> 86     return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
     87 
     88 

TypeError: invalid type promotion

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-90bc0078bbee> in <module>()
      6 # hv.Curve([0, 1, 2, 3]) * hv.VSpan(1, 2) * hv.HSpan(1, 5)
      7 
----> 8 hv.Curve((pd.date_range('2017-05-01', '2017-05-03'), [0, 1, 2])) * hv.HSpan(*pd.date_range('2017-05-01', '2017-05-02')) * hv.VSpan(1, 2)

~/anaconda3/lib/python3.6/site-packages/IPython/core/displayhook.py in __call__(self, result)
    255             self.start_displayhook()
    256             self.write_output_prompt()
--> 257             format_dict, md_dict = self.compute_format_data(result)
    258             self.update_user_ns(result)
    259             self.fill_exec_result(result)

~/anaconda3/lib/python3.6/site-packages/IPython/core/displayhook.py in compute_format_data(self, result)
    149 
    150         """
--> 151         return self.shell.display_formatter.format(result)
    152 
    153     # This can be set to True by the write_output_prompt method in a subclass

~/anaconda3/lib/python3.6/site-packages/IPython/core/formatters.py in format(self, obj, include, exclude)
    148             return {}, {}
    149 
--> 150         format_dict, md_dict = self.mimebundle_formatter(obj, include=include, exclude=exclude)
    151 
    152         if format_dict or md_dict:

TypeError: 'NoneType' object is not iterable

@philippjfr
Copy link
Member

Bokeh: no idea why it says I'm setting center=True; I didn't do that anywhere. I have a feeling annotation automatically passes that, but I can't find it.

Nothing to do with bokeh or this PR, you just need panel master.

@philippjfr philippjfr added type: feature A major new feature and removed status: WIP labels Oct 2, 2019
@philippjfr philippjfr added this to the v1.13.0 milestone Oct 2, 2019
@philippjfr
Copy link
Member

It seems you inverted the definition of HSpan and VSpan which caused numeric and datetime ranges to be combined causing the issues you saw. I've now added reference notebooks and tests and will merge.

@philippjfr philippjfr merged commit bb62cbf into master Oct 2, 2019
@philippjfr
Copy link
Member

Thanks @ahuang11!

@philippjfr philippjfr deleted the hspan_vspan branch October 2, 2019 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A major new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants