英文:
Min and max values in seaborn violinplot are invalid
问题
I'm plotting the distribution of daily returns from a stock index in a particular year using seaborn violinplot. However, some extreme values on the chart appear to be plotted improperly.
下面的图表是一年的示例。如您所见,'Piątek' 的最低值约为 -6。
我正在使用 seaborn 的 violinplot 函数绘制如下的数据:
sns.violinplot(x=wig20.iloc[1500:1751,3], y=wig20.iloc[1500:1751,2], width=1, order=['Poniedziałek','Wtorek','Środa','Czwartek','Piątek'])
数据如下所示:
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
然而,当我检查数据时,我发现最低值为:
wig20.iloc[1500:1751,2].min()
-4.533610974747937
因此,图表完全误导。在上述图表中,'Piątek' 的最低值明显低于 -5。我检查了不同年份的数据,似乎每个大于 4 的最大/最小值都接近图表上的 6,但我不知道为什么会这样。
英文:
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'])
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.
答案1
得分: 5
你可以将 cut=0
传递给 sns.violinplot
,以在小提琴图上剪切到最小和最大值。
英文:
You can pass cut=0
to sns.violinplot
to cut the violin plot at the minimum and maximum values.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论