Issue
I have a dataset like:
a1 = [81, 42, 73, 94, 85, 66]
a2 = [63, 55, 79, 65, 94, 76]
a3 = [3, 5, 4, 8, 7, 6]
I want to draw a scatter plot that the x_ticks will be a1, a2, a3 and the each y_tick is their scores, for example above a1 x_tick there's 6 dots.
Solution
From what I could make of the question, this could be one simple implementation:
import matplotlib.pyplot as plt
a1 = [81, 42, 73, 94, 85, 66]
a2 = [63, 55, 79, 65, 94, 76]
a3 = [3, 5, 4, 8, 7, 6]
plt.scatter(x=[0]*len(a1), y=a1)
plt.scatter(x=[1]*len(a2), y=a2)
plt.scatter(x=[2]*len(a3), y=a3)
plt.xticks(ticks=[0,1,2], labels=["a1", "a2", "a3"])
plt.show()
If you also want to only display the y values at the y axis you can add this line:
plt.yticks(ticks=a1+a2+a3, labels=a1+a2+a3)
But for y values that are very close to each other (see values for a3
) this will get crowded.
Answered By - Marcello Zago
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.