[英]Dotted Seaborn distplot
我想做一些點綴的線條。 我怎樣才能做到這一點? 我嘗試以兩種不同的方式使用linestyle並出現錯誤
#### approach 1
for x, m in x_list:
sns.distplot(x, hist=False, label=m, linestyle='--')
#### approach 2
for x, m in x_list:
sns.distplot(x, hist=False, label=m, kde_kws={'linestyle':'--'})
TypeError: distplot() got an unexpected keyword argument 'linestyle'
您可以使用ax.lines
從seaborn distplot返回的軸中獲取Line2D對象的列表。 然后,使用set_linesytle
遍歷這些對象,以設置所需的linestyle。
例如:
import seaborn as sns
x = np.random.randn(100)
ax = sns.distplot(x, hist=False)
[line.set_linestyle("--") for line in ax.lines]
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.