我想使用 Seaborn 制作类似于此的步骤图matplotlib 示例 https://stackoverflow.com/questions/8921296/how-do-i-plot-a-step-function-with-matplotlib-in-python
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')
The result should look like this:
![step plot](https://i.stack.imgur.com/DW5s0.png)
由于进一步的关键字参数sns.lineplot
被传递给matplotlib的plot函数,你可以直接使用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')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)