我想使用 Seaborn 制作类似于此的步骤图 matplotlib example
import seaborn as sns
x = [1,2,3,4]
y = [0.002871, 0.0051, 0.0086, 0.005]
sns.lineplot(x,y)
我可以使用drawstyle='steps-post'
吗?
以下内容不起作用:sns.lineplot(x,y, drawstyle='steps-pre')
最佳答案
由于 sns.lineplot
的更多关键字参数被传递给 matplotlib 的绘图函数,因此您可以直接使用 drawstyle
参数。以下在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()
或者类似地使用sns.lineplot(x,y,drawstyle='steps-post')
关于python - 如何使用 Seaborn 绘制阶跃函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51513570/