I'm creating a plot using these lines of code, pretty standard.
plt.plot(x, It)
plt.plot(x, NIt, dashes=[6,2])
plt.show()
Which gives me the following result:

Which is correct given the code I am using. However, I would like to use a graph that keeps the variable value until the value changes, i.e. an horizontal line until the value changes, at which point the dots are connected by a vertical line. So instead of the above (for the blue), I'd have something like the black line shown here (I did only the start to illustrate it, forgive my terrible paint skills):

Any way of doing this? Thanks in advance.
drawstyle = 'steps'option toplt.plot(). Writing a full answer below.