10

I am using seaborn to create violin plots. Right now I am creating violin plots out of proportion values (so all values are between 0 and 1), but the resulting violin plot is quite off. Its bottom ranges into negative values and its top ranges into values greater than 1. Below is an example which I ran to test it:

import seaborn as sns
import numpy as np
y = np.asarray([.1725,.1825,.163,.1625,.93,.943,.893,.93,.11225,.93,.812,.832,.9425,.953,.8525,.993,.963,.1425,.113,.752])
x = np.asarray([1]*len(data))
sns.violinplot(x=x,y=y)
sns.plt.show()

Clearly none of the values are outside of the range [0,1], yet the violin plot looks all screwy:

Violin plot that is out of range

Help would be greatly appreciated!

Nikos Tavoularis
  • 2,843
  • 1
  • 30
  • 27
Niema Moshiri
  • 909
  • 5
  • 14
  • 8
    This is due to the shape being estimated by a kernel density estimator. It does not know that values are constrained between 0 and 1. To get a proper understanding, you may want to familiarize yourself with kernel density estimation. – cel Oct 04 '16 at 08:29
  • 2
    See http://stackoverflow.com/a/28119908/419338 – mbatchkarov Oct 04 '16 at 09:21
  • Ah excellent, I wasn't aware of what I was looking for. Thanks for this! – Niema Moshiri Oct 04 '16 at 17:45

0 Answers0