0

When I apply options to a holoviews object (Element, Layout, Holomap, ...), is it possible to retrieve those options later on?

p=hv.Points(np.random.rand(100,2)).options(width=700, size=10, color='r')

Given p, (how) can I find width=700, size=10, color='r'?

I've gone through all the attributes of p and also looked through StoreOptions but to no avail.

doppler
  • 997
  • 5
  • 17

2 Answers2

3

You can get the printed representation of the options as follows:

p.opts.info()

Which will print something like:

:Points   [x,y]
 | Options(color='r', size=10, width=700)

If you need programmatic access to the settings, there is currently no public API (though it is planned). There is an internal API but using that is a little more involved...

jlstevens
  • 201
  • 1
  • 2
2

Just to elaborate on the internal API, you can use the following to get an ordered dictionary of the options set:

from holoviews import Store
options = Store.lookup_options(Store.current_backend, p, 'style')
options.kwargs

where options is an Options object containing just the 'style' options of object p (the distinction between 'style' and 'plot' options are described at the end of the user guide).

jlstevens
  • 201
  • 1
  • 2
  • Great! And for those who wonder, `Store.lookup_options(Store.current_backend, p, 'plot').kwargs` would give you the 'plot' options. – doppler Jan 30 '19 at 23:17
  • Having tried it in more depth, how would I go about retrieving options in nested objects? Say, if I had a Layout `p*p+p`? – doppler Jan 30 '19 at 23:23
  • 1
    I think you'll need to index through the layout/overlay to reach the element you want to check the options for. Then you should be able to use the same approach as above. – jlstevens Jan 31 '19 at 22:47