[英]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.