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

Exception when adding two layouts on matplotlib #1678

Closed
wjaskowski opened this issue Jul 4, 2017 · 4 comments
Closed

Exception when adding two layouts on matplotlib #1678

wjaskowski opened this issue Jul 4, 2017 · 4 comments
Milestone

Comments

@wjaskowski
Copy link

hv.extension('matplotlib')
def sin_curve(phase, freq):
    xvals = [0.1* i for i in range(100)]
    return hv.Curve((xvals, [np.sin(phase+freq*x) for x in xvals]))

def cos_curve(phase, freq):
    xvals = [0.1* i for i in range(100)]
    return hv.Curve((xvals, [np.sin(phase+freq*x) for x in xvals]))

phases      = [0, 1, 2]
frequencies = [0.5, 1.0, 1.5]
sin_curves = {(p,f):sin_curve(p,f) for p in phases for f in frequencies}
#del sin_curves[0, 1.0]
hmap_sin = hv.HoloMap(sin_curves, kdims=['phase', 'frequency'])

cos_curves = {(p,f):cos_curve(p,f) for p in phases for f in frequencies}
hmap_cos = hv.HoloMap(cos_curves, kdims=['phase', 'frequency'])

hmap_sin.layout(dimensions=['phase']) + hmap_cos.layout(dimensions=['phase'])

works fine with Bokeh but fails on Matplotlib:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    303                 pass
    304             else:
--> 305                 return printer(obj)
    306             # Finally look for special method names
    307             method = get_real_method(obj, self.print_method)

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in pprint_display(obj)
    257     if not ip.display_formatter.formatters['text/plain'].pprint:
    258         return None
--> 259     return display(obj, raw=True)
    260 
    261 

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in display(obj, raw, **kwargs)
    240     elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
    241         with option_state(obj):
--> 242             html = layout_display(obj)
    243     elif isinstance(obj, (HoloMap, DynamicMap)):
    244         with option_state(obj):

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in wrapped(element)
    129         try:
    130             html = fn(element,
--> 131                       max_frames=OutputSettings.options['max_frames'])
    132 
    133             # Only want to add to the archive for one display hook...

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in layout_display(layout, max_frames)
    211         return None
    212 
--> 213     return render(layout)
    214 
    215 

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
     59     if renderer.fig == 'pdf':
     60         renderer = renderer.instance(fig='png')
---> 61     return renderer.html(obj, **kwargs)
     62 
     63 

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in html(self, obj, fmt, css, comm, **kwargs)
    253         code to initialize a Comm, if the plot supplies one.
    254         """
--> 255         plot, fmt =  self._validate(obj, fmt)
    256         figdata, _ = self(plot, fmt, **kwargs)
    257         if css is None: css = self.css

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in _validate(self, obj, fmt)
    189         if isinstance(obj, tuple(self.widgets.values())):
    190             return obj, 'html'
--> 191         plot = self.get_plot(obj, renderer=self)
    192 
    193         fig_formats = self.mode_formats['fig'][self.mode]

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, renderer)
    176             plot = self_or_cls.plotting_class(obj)(obj, renderer=renderer,
    177                                                    **plot_opts)
--> 178             plot.update(0)
    179         else:
    180             plot = obj

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in update(self, key)
    243         if len(self) == 1 and key == 0 and not self.drawn:
    244             return self.initialize_plot()
--> 245         return self.__getitem__(key)
    246 
    247 

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/plot.py in __getitem__(self, frame)
    219         if isinstance(frame, int) and frame > len(self):
    220             self.warning("Showing last frame available: %d" % len(self))
--> 221         if not self.drawn: self.handles['fig'] = self.initialize_plot()
    222         if not isinstance(frame, tuple):
    223             frame = self.keys[frame]

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in wrapper(self, *args, **kwargs)
     41     def wrapper(self, *args, **kwargs):
     42         with _rc_context(self.fig_rcparams):
---> 43             return f(self, *args, **kwargs)
     44     return wrapper
     45 

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in initialize_plot(self)
   1067         ranges = self.compute_ranges(self.layout, key, None)
   1068         for subplot in self.subplots.values():
-> 1069             subplot.initialize_plot(ranges=ranges)
   1070 
   1071         # Create title handle

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in wrapper(self, *args, **kwargs)
     41     def wrapper(self, *args, **kwargs):
     42         with _rc_context(self.fig_rcparams):
---> 43             return f(self, *args, **kwargs)
     44     return wrapper
     45 

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in initialize_plot(self, ranges)
    639                 ax.set_axis_off()
    640                 continue
--> 641             subplot.initialize_plot(ranges=ranges)
    642 
    643         self.adjust_positions()

/Users/Wojciech/miniconda3/envs/rlzoo/lib/python3.6/site-packages/holoviews/plotting/mpl/plot.py in wrapper(self, *args, **kwargs)
     41     def wrapper(self, *args, **kwargs):
     42         with _rc_context(self.fig_rcparams):
---> 43             return f(self, *args, **kwargs)
     44     return wrapper
     45 

TypeError: initialize_plot() got an unexpected keyword argument 'ranges'
@jlstevens
Copy link
Contributor

This is something Philipp and have disagreed about - the .layout method returns an NdLayout and therefore does not support the + operator of Layout. See #1606 for the discussion.

@wjaskowski
Copy link
Author

NdLayout * NdLayout informs a user that this is disallowed but, as I have shown '+' works but only for Bokeh. So, something is wrong, anyway.

@jlstevens
Copy link
Contributor

I agree. It is odd that it works for Bokeh, I don't think it should...

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
None yet
Projects
None yet
Development

No branches or pull requests

3 participants