Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set bokeh plotting parameters using BOKEH + HOLOVIEW plotting option via Python

Is there any documentation specifying how to pass Bokeh parameters via holoview? I am reading the tutorials but I think there is something small I have missed. There is an example online which describes this in Ipython but I am trying to do it via a python WITHOUT Ipython notebook. http://holoviews.org/Tutorials/Bokeh_Backend.html?highlight=bokeh

When I run this program I get the curves but the color does not change and I also get this error: WARNING:root:Curve01537: Setting non-parameter attribute style={'line_color': 'green'} using a mechanism intended only for parameters

How can we set the parameter?

    Code Example here
    from pprint import pprint, pformat
    import holoviews as hv
    import numpy as np
    import pathlib, os
    import webbrowser
    import lasio, las
    from holoviews import Store
    from holoviews.plotting.bokeh.element import (line_properties, fill_properties, text_properties)

   def plot_bokeh(plot):

       #Create renderer instance
       myrenderer = hv.Store.renderers['bokeh'].instance(fig='html')
       out_file_name = "".join(["./OUTPUT/","gyro", "_graph.html"])
       with open (out_file_name, 'w') as f:
       #Plot static html
           f.write (myrenderer.static_html(plot))
       f.close()
                     webbrowser.open_new_tab(pathlib.Path(os.path.abspath(out_file_name)).as_uri())


    def holoview_sandbox():


      curve_opts = dict(line_color='green')
      xs = np.linspace(0, np.pi*4, 100)
      data = (xs, np.sin(xs))


      holo_plot = hv.Curve(data, label='MY LABEL' , style=curve_opts) 
      plot_bokeh(holo_plot)

    if __name__ == '__main__':
        holoview_sandbox()
like image 488
pyenthu Avatar asked Jun 28 '26 03:06

pyenthu


1 Answers

In HoloViews the options aren't bound to the objects themselves, which has various benefits including being able to plot with different backends. The pure-Python way of setting style options is this:

  curve_opts = dict(line_color='green')
  xs = np.linspace(0, np.pi*4, 100)
  data = (xs, np.sin(xs))
  holo_plot = hv.Curve(data, label='MY LABEL')(style=curve_opts)

The Options Tutorial describes how to set options like this, but please let us know if you found some of that unclear.

like image 153
philippjfr Avatar answered Jun 30 '26 11:06

philippjfr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!