How To Produce Plot With Text As Ytick Labels
I am just getting to know the Python libraries pandas and matplotlib. Can you show me as an example how to produce a plot similar to this one with matplotlib: On the y-axis to the
Solution 1:
import random
import matplotlib.pyplot as plt
labels = [chr(j) for j inrange(97, 115)]
fake_data1 = [random.random() for l in labels]
fake_data2 = [random.random() for l in labels]
y_data = range(len(labels))
figure()
ax = gca()
ax.grid(True)
ax.scatter(fake_data1, y_data, color='r')
ax.scatter(fake_data2, y_data, color='b')
ax.set_yticks(range(len(labels)))
ax.set_yticklabels(labels)
ax.invert_xaxis()
plt.draw()
Where labels
is a list of your labels, y_data
is indices of the labels for each data point, and fake_data1
and fake_data2
are you x
values.
Post a Comment for "How To Produce Plot With Text As Ytick Labels"