question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plot options not applied when changed interactively

See original GitHub issue

Hi everyone,

I currently have the problem that I cannot change the options of my plot through interactivity with parambokeh. An example code is as follows:

def density_view(det_den, ran, main_axes=1):
    nature_list = ['All'] + list(ran.to_dict()['name'].values())
    curr_den = np.swapaxes(det_den, 1, main_axes)
    
    class DensityView(Stream):
        slider1 = param.Integer(default=10, bounds=(0, np.shape(curr_den)[main_axes]-1))
        colormap1 = param.ObjectSelector(default="gray", objects=["gray", "jet", "fire"])
        nature = param.ObjectSelector(default="All", objects=nature_list)
        cbar = param.Boolean(True)

        def view(self, xrange=None, yrange=None, **kwargs):
            nature_index = nature_list.index(str(self.nature)) - 1
            curr_density = curr_den[nature_index, :, :, :] 
            
            options = dict(colorbar=self.cbar, xaxis=None, yaxis=None, cmap=str(self.colormap1))
            im = hv.Image(np.squeeze(curr_density[self.slider1, :,:])).opts(plot=options)
            return im
    return DensityView()  

So, when I change the cmap param or cbar param, it does not change interactively. I have to replot for seeing the change, whereas the slider and nature params are interactive.

Plotting is started like this:

det_explorer = density_view(det_density, ran)
parambokeh.Widgets(det_explorer, callback=det_explorer.event)
hv.DynamicMap(det_explorer.view, streams=[det_explorer])

Backend is matplotlib.

Versions: param – 1.6.1 parambokeh – 0.2.2 matplotlib – 2.2.2 holoviews – 1.10.7

Please tell me if you need more information.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
philippjfrcommented, Oct 25, 2018

I’d strongly recommend looking into http://panel.pyviz.org which is an infinitely superior replacement for parambokeh.

0reactions
MHC03commented, Nov 7, 2018

Here I have found out that this problem mostly occurs in matplotlib. So, in matplotlib no option change is dynamic, in bokeh almost all are dynamic except options like activating/deactivating cbar.

Example:

dynamic_options

Code:

import param
import numpy as np
import holoviews as hv
import parambokeh
from holoviews.streams import Stream
hv.notebook_extension('bokeh', 'matplotlib', logo=False)

image = np.random.randn(4, 4, 4)

class Options(Stream):
    given_cmap = param.ObjectSelector(default='gray', objects=['gray', 'jet', 'fire'])
    given_cbar = param.Boolean(False)
    
def show(given_cmap='gray', given_cbar=False):
    return hv.Image(image).options(cmap=given_cmap, colorbar=given_cbar)

# %%output backend='matplotlib'
option_stream = Options()
parambokeh.Widgets(option_stream, callback=option_stream.event)
hv.DynamicMap(show, streams=[option_stream])
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bokeh interactively changing the columns being plotted
I just want a single plot where I can interactively change the columns used for the x and y axis and the plot...
Read more >
Changing plot settings — splash v3.4.0 documentation
The position of the time legend can be set interactively by positioning the mouse in the plot window and pressing 'G'. To set...
Read more >
Modifying the Plot - MATLAB & Simulink
To change the properties of a plot, first click the Send to Figure button in the toolstrip to open a new figure window...
Read more >
Plot Live, Changing Data - ScottPlot FAQ
After plotting an array you can change its values and re-render at any time. This is the most performant option for displaying changing...
Read more >
Interactive Plots — FiftyOne 0.18.0 documentation
view changes. View plots can be used to construct dynamic dashboards that update to reflect the contents of your current view. More view...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found