I have a list of values x that I want to plot (with lines) against the y axis.
That is, if x = [3, 5, 2, 4] and y = ['A', 'B', 'C', 'D'], the plot might look like this (except not hand-drawn):

And I'm afraid I don't see anything in the matplotlib.pyplot docs / SO / google pointing me in the right direction, even what to call it. Any pointers?
I think you look for something like this
import numpy as np
import matplotlib.pyplot as plt
fig,ax = plt.subplots(1)
# create some x data and some integers for the y axis
x = np.array([3,5,2,4])
y = np.arange(4)
# plot the data
ax.plot(x,y)
# tell matplotlib which yticks to plot
ax.set_yticks([0,1,2,3])
# labelling the yticks according to your list
ax.set_yticklabels(['A','B','C','D'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With