overb
overb

Reputation: 187

Min and max values in seaborn violinplot are invalid

I'm plotting the distribution of daily returns from stock index in a particular year using seaborn violinplot. However some extreme values on the chart looks to be plotted improperly.

The chart below is an example for one year. As you can see the lowest value for 'Piątek' is something near -6.

sns.violinplot( x=wig20.iloc[1500:1751,3], y=wig20.iloc[1500:1751,2], width=1, order=['Poniedziałek','Wtorek','Środa','Czwartek','Piątek'])

Example

Data looks like:

wig20.iloc[1500:1751,0:4].head()

           Date      wig20     [%]       weekday
1500    2016-01-04  1804.42 -2.943818   Poniedziałek
1501    2016-01-05  1792.01 -0.687756   Wtorek
1502    2016-01-07  1745.46 -2.597642   Czwartek
1503    2016-01-08  1725.14 -1.164163   Piątek
1504    2016-01-11  1703.78 -1.238160   Poniedziałek

However when i checked the data i can see

wig20.iloc[1500:1751,2].min()

-4.533610974747937

So the chart is completely missleading. On the chart above the low for 'Piątek' is definitely below -5. I checked diffrent years and it seems that every max/min value of more than 4 is near the 6 on the chart and i have no clue why it is that way.

Upvotes: 5

Views: 4972

Answers (1)

Saurabh Parikh
Saurabh Parikh

Reputation: 81

You can pass cut=0 to sns.violinplot to cut the violin plot at the minimum and maximum values.

Upvotes: 8

Related Questions