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

Backend error when styling elements rendered with Bokeh #824

Closed
pyenthu opened this issue Aug 19, 2016 · 7 comments
Closed

Backend error when styling elements rendered with Bokeh #824

pyenthu opened this issue Aug 19, 2016 · 7 comments

Comments

@pyenthu
Copy link

pyenthu commented Aug 19, 2016

I am not sure if this is an issue but I get an error trying to set the parameters via python (not Notebook) for bokeh backend.
Example:

I have asked for help on stackoverflow but just wanted to check if this is an issue or I am doing something wrong. Please excuse me if it is the latter.
If I try this
dict(line_color='green')
holo_plot = hv.Curve(data, label='MY LABEL' , style=curve_opts)
myrenderer = hv.Store.renderers['bokeh'].instance(fig='html')
out_file_name = "".join(["./OUTPUT/","gyro", "_graph.html"])
I get the following error
WARNING:root:Curve01536: Setting non-parameter attribute curve_opts={'line_color': 'green'} using a mechanism intended only for parameters

@pyenthu
Copy link
Author

pyenthu commented Aug 19, 2016

I also tried to set the parameters as we would in an IPython notebook. Noticed that the warning disappeared but the plot remained the same. I could also add a number of junk parameters and it would make no difference to the plot itself. I am using the static_html method to plot.

@philippjfr
Copy link
Member

Just to keep the discussion in one place, here's my reply on StackOverflow.

I just tried it myself and this seems to work fine for me:

import numpy as np
import holoviews as hv

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)
renderer = hv.Store.renderers['bokeh']
with open('test.html', 'w') as f:
    f.write(renderer.static_html(holo_plot))

Could you confirm whether that works for you?

@pyenthu
Copy link
Author

pyenthu commented Aug 19, 2016

Thanks a lot for your reply. I will keep the discussion on this forum going forward.

So tried your code snippet and got the following error:
Traceback (most recent call last): File "C:/Users/HP/Dropbox/SW PROJECTS/MAIN_ROOT/HOLOVIEW_PACK/__init__.py", line 29, in <module> holo_plot = hv.Curve(data, label='MY LABEL')(style=curve_opts) File "C:\Users\HP\MYVENV\lib\site-packages\holoviews\core\dimension.py", line 886, in __call__ groups = set(Store.options().groups.keys()) File "C:\Users\HP\MYVENV\lib\site-packages\holoviews\core\options.py", line 866, in options return cls._options[backend] KeyError: 'matplotlib'

@pyenthu
Copy link
Author

pyenthu commented Aug 19, 2016

Could not get it to work if I use holoviews.Store.renderer
So i tried to import holoviews.plotting.bokeh.Store
At least with this I could plot the file. But the parameters are ignored.
Maybe a version issue?

@jlstevens
Copy link
Contributor

@pyenthu Do you have matplotlib installed? This might be the issue...

The error you posted looks like a backend issue to me. We currently have some functionality in the bokeh backend that relies on matplotlib and perhaps you don't have matplotlib installed. We hope to remove this dependency on matplotlib in future, so people with only bokeh installed can use it without problem.

I've filed an issue to remind us to remove the need for matplotlib (#829) and I've updated the title of this issue as I believe the problem is related to how we handle backends.

@jlstevens jlstevens changed the title SETTING PARAMETERS FOR BOKEH VIA PYTHON Backend error when styling elements rendered with Bokeh Aug 23, 2016
@philippjfr
Copy link
Member

The issue is probably some combination of the following:

  1. You may not have matplotlib installed which can be an issue.
  2. You have to import the backend you want to use, which is why using holoviews.plotting.bokeh.Store worked.
  3. If you want to set options via the call method the current_backend needs to be set correctly on the renderer, here is the full working example:
import numpy as np
import holoviews as hv
import holoviews.plotting.bokeh

hv.Store.current_backend = 'bokeh'

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)
renderer = hv.Store.renderers['bokeh']
with open('test.html', 'w') as f:
    f.write(renderer.static_html(holo_plot))

I will close, please reopen if you encounter any more issues.

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 25, 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