I am plotting a series of 5 plots using matplotlib. However, I would like the tick marks per plot to be at 0 on the y axis instead of at the bottom of the plot (negative on the y axis). In the picture attached you can see the x axis tick marks are sort of floating below 0.
I'm currently plotting this line at 0 on the y-axis by physically calling:
ax[i].plot(np.zeros(300), linewidth=1, color='black'), however I realise this might not be the best way and there's something I'm missing to raise the x axis and its tick marks up without having to set it as invisible?
Is there an equivilent for this command to set the x axis tick marks to the middle? ax.xaxis.set_ticks_position('middle') Unfortunately looks like there is only 'top' or 'bottom'
Thanks for any help!
to_plot : A Numpy array of shape: (5, 300)
fig, ax = plt.subplots(5, 1, figsize=(12, 7))
plt.tight_layout()
plt.margins(0)
# ax[axis].set_ylabel("Attention Score (a.u.)", family='Arial', fontsize=15)
# ax[axis].set_xlabel("Timestep", family='Arial', fontsize=15)
for axis in range(5):
ax[axis].spines['top'].set_visible(False)
ax[axis].spines['right'].set_visible(False)
ax[axis].spines['bottom'].set_visible(False)
ax[axis].set_ylim([-0.004, 0.006])
ax[axis].set_xlim([0, 300])
for i, line in enumerate(to_plot):
ax[i].plot(np.zeros(len(line)), linewidth=1, color='black')
ax[i].plot(line, linewidth=1)
plt.show()