matplotlib步骤函数中的Linestyle

use*_*207 18 python matplotlib linestyle

是否可以将matplotlib步骤函数中的linestyle设置为虚线,点线等?

我试过了:

step(x, linestyle='--'), 
step(x, '--')
Run Code Online (Sandbox Code Playgroud)

但它没有帮助.

tac*_*ell 32

从mpl 1.3.0开始,这是固定的上游


你必须稍微侧身,因为step似乎忽略了linestyle.如果你看看step底下做了什么,它只是一个薄的情节包装.

你可以通过plot直接交谈来做你想做的事:

import matplotlib.pyplot as plt

plt.plot(range(5), range(5), linestyle='--', drawstyle='steps')
plt.plot(range(5), range(5)[::-1], linestyle=':', drawstyle='steps')
plt.xlim([-1, 5])
plt.ylim([-1, 5])
Run Code Online (Sandbox Code Playgroud)

例

['steps', 'steps-pre', 'steps-mid', 'steps-post']drawstyle是绘制步骤的有效值和控制步骤.

拉出这个问题的请求,我个人认为这是一个bug.[编辑:这已被拉入主人并且应该出现在v1.3.0中].