lundi 13 juin 2016

scatter plot same point repeated several times python


I am trying to draw a scatter plot from a dictionary bellow:

data_dict = {12: [1, 17, 11, 17, 1, 14, 38], 13: [13, 6, 4, 6], 14: [15, 8, 20, 8, 7], 15: [2, 3, 3, 1], 16: [62, 13, 36, 3, 8, 99, 54], 17: [1], 18: [44, 30, 36, 14, 21, 13, 44, 1, 62, 36], 19: [5, 5], 20: [27, 42, 42, 18, 31, 55, 31, 55], 21: [59, 1, 42, 17, 66, 26, 18, 4, 36, 42, 20, 54, 44, 35]}

I am using the following code to draw a scatter plot where dictionary keys are the x values are the values are the corresponding values.

for xe, ye in data_dict.iteritems():
    plt.scatter([xe] * len(ye), ye)

And getting this plot:

enter image description here

I'de like to be able to distinguish between just having one point at a given x and y location vs having multiple point. For example for x = 12, y = 1 and 17 are repeated twice. I'm looking in a way of representing this repetition by either color or size of the data points.

I could not find any reference on how to do this. I would appreciate any help or guidance.

Thanks.


Aucun commentaire:

Enregistrer un commentaire