Hopobcn
Hopobcn

Reputation: 905

How to use a matplotlib backend in holoviews

I'm trying to use HoloViews inside a python console instead of using it inside a jupyter/Ipython notebook.

To do that I tried to follow the example from the FAQ:

from holoviews import Store
renderer = Store.renderers['matplotlib'].instance(fig='svg', holomap='gif')
renderer.save(my_object, 'example_I', style=dict(Image={'cmap':'jet'}))

But apparently I don't have any backend available!:

$ python
Python 2.7.6 (default, Oct 26 2016, 20:22:54) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from holoviews import Store
>>> Store.renderers
OrderedDict()

Does anyone know if this is the intended behaviour or if my installation is broken?

I have HoloViews 1.6.2 (with pip) and Matplotlib 1.3.1 (from ubuntu)

Upvotes: 4

Views: 797

Answers (1)

philippjfr
philippjfr

Reputation: 4080

You'll have to import the backend first. The notebook_extension does this automatically but when working with Renderers directly you'll have to manually import the backend like this:

from holoviews import Store
import holoviews.plotting.mpl
renderer = Store.renderers['matplotlib'].instance(fig='svg', holomap='gif')
renderer.save(my_object, 'example_I', style=dict(Image={'cmap':'jet'}))

We'll make sure to update the FAQ example.

Upvotes: 4

Related Questions