Search code examples
pythonhvplotholoviz

How do i get a horizontal violin plot or boxplot? (default is vertical in hvplot holoviews)


Hvplot plots default a vertical violinplot or boxplot. See example below.
How do I get this to be a horizontal plot? So basically I would like to rotate this plot.

import numpy as np
import pandas as pd
import hvplot
import hvplot.pandas

df = pd.DataFrame(np.random.normal(size=[100, 2]), columns=['col1', 'col2'])
plot_hvplot = df.hvplot(kind='box')

vertical boxplot


Solution

  • You can do this by adding argument invert=True, like this:

    plot_hvplot = df.hvplot(kind='box', invert=True)
    

    or by using method .opts(invert_axes=True):

    plot_hvplot = df.hvplot(kind='box').opts(invert_axes=True)
    

    enter image description here