2016-09-15 94 views
0

我使用matplotlib.pyplot陰謀策劃()方法中加入數據:刪除折線在matplotlib

import matplotlib.pyplot as plt 
import matplotlib 
#matplotlib.style.use('ggplot') 

plt.plot(df_both_grouped['TSD_mean'], df_both_grouped['hgd_mean'], 'or', color = 'blue') 
plt.errorbar(df_both_grouped['TSD_mean'], df_both_grouped['hgd_mean'], yerr = df_both_grouped['TSD_err'], xerr = df_both_grouped['home_goal_err'], color = 'blue') 

一切都很正常,除了我似乎無法擺脫連接我的觀點(惱人的鋸齒線下面的例子)。

enter image description here

N.B:有一個額外的配件行我想保留。爲了簡潔,我沒有添加代碼。

是否有一個論點,我需要添加/刪除?我相信這是一個簡單的問題,但它令我瘋狂;)

在此先感謝!

回答

1

您正在查找fmt參數錯誤代碼方法。

只需更改您的代碼

import matplotlib.pyplot as plt 
import matplotlib 
#matplotlib.style.use('ggplot') 

plt.plot(df_both_grouped['TSD_mean'], df_both_grouped['hgd_mean'], 'or', color = 'blue') 
plt.errorbar(df_both_grouped['TSD_mean'], df_both_grouped['hgd_mean'], yerr = df_both_grouped['TSD_err'], xerr = df_both_grouped['home_goal_err'], color = 'blue', fmt='None') 

如記錄here (errorbar)擺脫連接線的。

其實,你也可以使用線型LS參數(從resutling Line2D正在添加的對象),就像普通的情節命令。

plt.errorbar(df_both_grouped['TSD_mean'], df_both_grouped['hgd_mean'], yerr = df_both_grouped['TSD_err'], xerr = df_both_grouped['home_goal_err'], color = 'blue', ls='None') 
+0

謝謝你,雅各布! –