2021年1月15日星期五

scatter plot to also represent the repetition of values using color bar

I'm trying to make a scatter plot to also represent the number of times a specific value occurs, the data set is quiet simple and looks somewhat like this:

x = [555,..690,.., 300]     Y = [3,..3.5,.., 8.6]  

with Y having many repeated values

I used very simple code:

plt.scatter(x, y, s=100, c= y, cmap='PiYG', marker='o', edgecolors='black', linewidth=1, alpha=0.7)    plt.colorbar();  

to have a output like this:

enter image description here

I realise with this, that I'm associating a specific colour for each value of Y, but instead I would like the colour bar to represent the number of times a certain value of Y is repeated.

Could someone please tell me how that would be possible?

https://stackoverflow.com/questions/65744285/scatter-plot-to-also-represent-the-repetition-of-values-using-color-bar January 16, 2021 at 06:20AM

没有评论:

发表评论