[英]How do I plot a step function with Seaborn?
I want to make a step plot using Seaborn similar to this matplotlib example 我想使用Seaborn制作类似于此matplotlib示例的阶梯图
import seaborn as sns
x = [1,2,3,4]
y = [0.002871, 0.0051, 0.0086, 0.005]
sns.lineplot(x,y)
Can I make use of drawstyle='steps-post'
? 我可以使用drawstyle='steps-post'
吗?
The following does not work: sns.lineplot(x,y, drawstyle='steps-pre')
以下内容不起作用: sns.lineplot(x,y, drawstyle='steps-pre')
Since further keyword arguments to sns.lineplot
are passed on to matplotlib's plot function, you may directly use the drawstyle
argument. 由于将sns.lineplot
其他关键字参数传递给matplotlib的plot函数,因此您可以直接使用drawstyle
参数。 The following works fine in seaborn 0.9.0 and matplotlib 2.2.2. 以下在seaborn 0.9.0和matplotlib 2.2.2中可以正常工作。
import matplotlib.pyplot as plt
import seaborn as sns
x = [1,2,3,4]
y = [0.002871, 0.0051, 0.0086, 0.005]
sns.lineplot(x,y, drawstyle='steps-pre')
plt.show()
Or similarly with sns.lineplot(x,y, drawstyle='steps-post')
或类似地与sns.lineplot(x,y, drawstyle='steps-post')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.