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

Objects produced by renderer.get_plot do not display in the notebook #2587

Closed
abourrier opened this issue Apr 20, 2018 · 8 comments
Closed
Milestone

Comments

@abourrier
Copy link

Since holoviews 1.9.10, this code

import holoviews as hv
hv.extension("bokeh")
renderer = hv.renderer("bokeh")
curve = hv.Curve(range(10))
curve_plot = renderer.get_plot(curve)
curve_plot

yields a text output instead of the proper figure:

CurvePlot(apply_extents=True, apply_ranges=True, bgcolor=None, border=10, default_tools=['save', 'pan', 'wheel_zoom', 'box_zoom', 'reset'], finalize_hooks=[], fontsize={'title': '12pt'}, gridstyle={}, height=300, interpolation='linear', invert_axes=False, invert_xaxis=False, invert_yaxis=False, labelled=['x', 'y'], lod={'factor': 10, 'interval': 300, 'threshold': 2000, 'timeout': 500}, logx=False, logy=False, name='CurvePlot01090', normalize=True, projection=None, shared_axes=True, shared_datasource=True, show_frame=True, show_grid=False, show_legend=True, show_title=True, sizing_mode='fixed', title_format='{label} {group} {dimensions}', toolbar='right', tools=[], width=300, xaxis='bottom', xrotation=None, xticks=None, yaxis='left', yrotation=None, yticks=None)

It seems to work neither with matplotlib backend nor with other types of figures.

@abourrier abourrier changed the title Objects produced by Renderer.get_plot do not display in the notebook Objects produced by renderer.get_plot do not display in the notebook Apr 20, 2018
@jlstevens
Copy link
Contributor

If I remember correctly, there was a thing to make the plotting classes themselves display themselves with the display hooks. I assume that will no longer work with the changes made for Jupyterlab compatibility (@philippjfr ?) ...

This was really meant as a convenience for developers and not for users. @abourrier Why not just view curve?

@abourrier
Copy link
Author

In my use case, I have (x,y,z) aggregated data that I visualize as a DynamicMap of HeatMaps ((x,y) being the HeatMap kdims and z being the DynamicMap kdim). I want to bind the click on a particular square of the current HeatMap to a python callback (which will load the corresponding chunk of data and represent it in detail inside a different figure). The problem with defining a Tap stream bound to the DynamicMap is that I only have access to the (x,y) information and not to the current value of z.

As a workaround to this limitation, I previously used the renderer feature to get a handle on the figure, so that I could access at any moment the fig.current_key item which would give me the current z value in my callback.

@philippjfr
Copy link
Member

As a workaround to this limitation, I previously used the renderer feature to get a handle on the figure, so that I could access at any moment the fig.current_key item which would give me the current z value in my callback.

Sounds like you'd be much better served by some extension to this #604 which would make the last displayed frame and key available.

For the time being I'd be in favor of supporting Plot instances in the display function and I've opened a PR to that effect here: #2589

I'd only recommend using that for debugging or for the time being as a workaround.

@philippjfr
Copy link
Member

Usage would be as follows:

obj = hv.Curve([1, 2, 3])
plot = hv.renderer('bokeh').get_plot(obj)
hv.ipython.display(plot)

@abourrier
Copy link
Author

Making the latest key available would indeed be sufficient and more practical in the mentioned use case.

Additionally, my colleagues and I use plot handles when we want to finely customize the plot, such as modifying xlabels fonts/colors. It is sometimes very useful to have fine-grained control over the plot to maximize the amount of information conveyed by the visualization. Therefore being able to get a handle on the plot produced by holoviews is still pretty useful to us, even though it may not be the initial intent.

@philippjfr
Copy link
Member

Additionally, my colleagues and I use plot handles when we want to finely customize the plot, such as modifying xlabels fonts/colors. It is sometimes very useful to have fine-grained control over the plot to maximize the amount of information conveyed by the visualization. Therefore being able to get a handle on the plot produced by holoviews is still pretty useful to us, even though it may not be the initial intent.

That's true, although we do provide a mechanism to do that via the finalize_hooks which let you define function to customize the plot, e.g.:

def customize_plot(plot, element):
    plot.handles['xaxis'].major_label_text_color =  'red'
    plot.state.border_fill_color = 'gray'

hv.Curve([1, 2, 3]).options(finalize_hooks=[customize_plot])

@philippjfr
Copy link
Member

The change to allow the display function to display plots is now merged so I'll close this.

@philippjfr philippjfr added this to the v1.10.2 milestone Apr 24, 2018
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