2

In python, suppose that I were to plot a scatter plot as follows,

sc = plt.scatter(x_data, y_data, c=color_vector, s=size_vector, cmap=cmap, norm=norm)

I know I can get x_data, y_data from sc using sc.get_offsets(), but how about the values color_vector, size_vector?

Andrew Yuan
  • 209
  • 1
  • 7
  • Does this answer your question? https://stackoverflow.com/questions/47908429/get-color-of-a-scatter-point – Fried Noodles Oct 04 '20 at 07:41
  • I don't think so. If I'm understanding that question correctly, it seems to return the `cmap(norm(color_vector))`, but I would like to obtain the `color_vector`. For example, if `color_vector = [1,2,3,4,5]`, how would I obtain this from `sc`. – Andrew Yuan Oct 04 '20 at 07:44
  • @AndrewYuan I am curious why you want to get the values this way? since you are plotting the data can't you take data directly from color_vector? – Equinox Oct 04 '20 at 07:56
  • I'm trying to write a class so that if my mouse hovers over a scattered point, it will show the corresponding color value/size value. I know that I can just have `color_vector, size_vector` as my inputs when first initializing the class, but I would prefer to have `sc` as my only argument. – Andrew Yuan Oct 04 '20 at 07:58

1 Answers1

1

I think sc.get_sizes() and sc.get_array() will do the trick.

Jan Kuiken
  • 1,930
  • 17
  • 17