簡體   English   中英

刪除 matplotlib seaborn 點圖中的垂直線

[英]Remove vertical lines in matplotlib seaborn pointplots

我在 seaborn 中的 Pointplot 樣式有問題,並嘗試了一切來修復它,但似乎沒有任何效果。 你可以在下面看到我原來的dataframe

    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

在這個 DF 上,我運行這些命令並得到下面的結果圖

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()

在此處輸入圖像描述

我的問題是點系列開始和結束處的 X 軸垂直線。
有沒有辦法去除這些垂直線?

這些垂直線代表置信水平,如sns.pointplot文檔中所述。 如果您不想在圖表中顯示它們,請查看sns.lineplot

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM