I want to plot a velocity versus depth model using the given data.
import matplotlib.pyplot as plt
import numpy as np
depth=np.array((0.0,5.0,30.0,40.0,50.0))
velocity=np.array((5.5,6.5,6.8,9.0,10.0))
plt.plot(velocity,depth)
plt.show()
But this script doesnot give the plot as i expected
I need something like example_plot
I hope experts may help me overcoming this problem. Thanks in advance.
>Solution :
You have to use matplotlib.pyplot.step
depth=np.array((0.0,5.0,30.0,40.0,50.0))*-1
velocity=np.array((5.5,6.5,6.8,9.0,10.0))
plt.step(velocity,depth)
plt.show()
EDIT:
depth=np.array((0.0,5.0,30.0,40.0,50.0))
velocity=np.array((5.5,6.5,6.8,9.0,10.0))
fig, ax = plt.subplots()
ax.step(velocity,depth)
ax.invert_yaxis()
fig.show()