Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate an element in Holoviews

Is there a way to rotate a plot 90° within Holoviews?

I'm interested in knowing how to do that generally, but my immediate purpose is to generate a histogram that is rotated to put the frequency on the horizontal and key value on the vertical to layout next to a scatter.

This can be done quite nicely with the .hist() command, unfortunately the object that's generated (AdjointLayout) can't be nested in a HoloMap or GridSpace, so I'm left to my own devices.

import numpy as np
import holoviews as hv
hv.extension('bokeh')

data1=np.random.randn(1000)
data2=np.random.rand(1000)

dataDict1={1:hv.Scatter(data1)+hv.Histogram(np.histogram(data1),kdims=['y']),
           2:hv.Scatter(data2)+hv.Histogram(np.histogram(data2),kdims=['y'])}

dataDict2={1:hv.Scatter(data1).hist(), 2:hv.Scatter(data2).hist()}

hv.HoloMap(dataDict1).collate()  #yay!
hv.HoloMap(dataDict2).collate()  #TypeError: HoloMap does not accept AdjointLayout type, data elements have to be a ('ViewableElement', 'NdMapping', 'Layout').

I suspect it's one of the %%opts or .opts() plot options in square brackets, but I can't find the available options documented (the links are either broken, or point to the top of the API guide and I haven't found the right section of the API.)

like image 797
Omegaman Avatar asked Aug 26 '17 21:08

Omegaman


Video Answer


1 Answers

%%opts Histogram [invert_axes=True]

invert_xaxis reverses an axes, but invert_axes swaps the x and y axes.

The available options are much better documented through the hv.help() mechanism. ie. hv.help(hv.Histogram)

like image 82
Omegaman Avatar answered Oct 02 '22 01:10

Omegaman