0

I've N plots and i want to show the plots in M*N layout where M=1,2,3,.....

    import holoviews as hv
    from bokeh.layouts import layout as bk_lyout
    from bokeh.layouts import row, column
    from bokeh.models import (HoverTool, Panel, CustomJS)
    from bokeh.models.widgets import (Tabs, Select, Button)
    from bokeh.models.widgets.inputs import AutocompleteInput
    from dask import dataframe as dd
    from bokeh.core.enums import SizingMode
    from holoviews.operation.datashader import datashade
    
    def get_vmap(x, y, label=''):
        if x not in cols or y not in cols:
            return None
        hover = HoverTool(tooltips=[('x-value', '@' + x + '{%F %H:%M:%Ss %6Nms}'),
                                    ('y-value', '$y')],
                          formatters={'@timestamp': 'datetime'})
        curve_generated = curve(x, y, label=label)
        vmap = datashade(curve_generated, normalization='linear').opts(width=400, height=400)

        range_stream = hv.streams.RangeX(source=curve_generated)
        filtered_zoom = curve_generated.apply(xrange_filter, streams=[range_stream])
        hover_enabled = filtered_zoom.opts(tools=[hover])
        # hover_enabled = hv.util.Dynamic(aggregate(curve_generated, width=50, height=50), operation=hv.QuadMesh).opts(tools=[hover], alpha=0, hover_alpha=0.1)
        return vmap * hover_enabled

     plot_layout = column(children=[]) 
     def modify_doc(doc):
        plots = []
        for key, value in PLOT_INFO.items():
            overlay_plots = []
            for carrier in range(7):
                car_value = value.format(carrier)
                plot_label = "{}-Carrier_{}".format(key.split("_vs_")[1], carrier)
                carrier_plot = get_vmap('timestamp', car_value, label=plot_label)
                if carrier_plot is not None:
                    print('\n Found plot for Carrier {}, {}'.format(carrier, carrier_plot))
                    overlay_plots.append(carrier_plot)

            overlaid_plot = None
            for plot in overlay_plots:
                overlaid_plot = overlaid_plot * plot if overlaid_plot is not None else plot
            #overlaid_plot = hv.Overlay(overlay_plots).collate()
            if overlaid_plot is not None:
                try:
                    hv_overlay_plot = renderer.get_plot(overlaid_plot, doc)
                    hv_overlay_plot = bk_lyout([[hv_overlay_plot.state]], sizing_mode='fixed')
                    select.js_link('value', hv_overlay_plot, 'sizing_mode')
                    plots.append(hv_overlay_plot)
                    plot_layout.children.append(hv_overlay_plot)
                except Exception as e:
                    print(e)
      tab = Panel(child=plot_layout, title='Interactive Dashboard')

Here plot_layout.children has list of plots and i want to show them in M*N. for example 10 plots, 2 in each row and user should have option to modify it like select 5 plots then 2 rows.

Mukesh Kumar
  • 333
  • 1
  • 5
  • 20
  • if you have a layout with all your plots in it, you can do .cols(3) to specify you would like 3 columns, so code looks like this: your_layout.cols(3) – Sander van den Oord Sep 03 '20 at 14:14
  • since `plot_layout = column(children=[])` has all the plots so should i do `plot_layout.cols(3)` ? remember We are converting back to bokeh plot from holoviews by `bk_plot = bk_lyout([[hv_overlay_plot.state]], sizing_mode='fixed')` line. can you please point out the specific point in this example. really appreciate your help – Mukesh Kumar Sep 04 '20 at 01:55

0 Answers0