简体   繁体   中英

Remove vertical lines in matplotlib seaborn pointplots

I have a problem with my Pointplot styling in seaborn and tried eveything to fix it but nothing seems to work. You can see my original dataframe below

    year  künstliche intelligenz   ki  artificial intelligence  ai
0   2000                      28   16                        4   0
1   2001                       0    0                        0   0
2   2002                       0    0                        0   0
3   2003                       4    0                        0   0
4   2004                       0    0                        0   0
5   2005                       0    0                        0   0
6   2006                       8    0                        0   0
7   2007                      12    0                        0   0
8   2008                       0    0                        0   0
9   2009                       0    0                        0   0
10  2010                       4    0                        0   0
11  2011                       4    0                        0   0
12  2012                       4    0                        0   0
13  2013                       4    0                        0   0
14  2014                      12    0                        0   0
15  2015                      48   24                        8  48
16  2016                      88   92                        8   4
17  2017                      96   48                        0   0
18  2018                     124  124                        4   0
19  2019                      84  292                        0   0
20  2020                      28    8                        0   0

on this DF I run these commands and get the resulting graph below

data = data.melt('year', var_name='cols', value_name='vals')

fig, ax = plt.subplots(figsize=(6.3792, 6.3792))
sns.pointplot(x="year", y="vals", hue='cols', data=data, colors=sns.color_palette('colorblind'), scale=0.4,
                 ci=None)
ax.set(yscale='log')
ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
ax.set_yticks([1, 2, 4, 8, 16, 32, 64, 128, 256, 512])
ax.set_xticklabels(ax.get_xticklabels(), rotation=30)
plt.show()

在此处输入图像描述

my problem are the vertical lines to the X-Axis at the beginning and end of a point series.
Is there a way to remove these vertical lines?

Those vertical lines represent confidence levels , as stated in docs for sns.pointplot . If you don't want to show them in the chart, take a look at sns.lineplot .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM