How to set marker for a specific point in a scatter plot with colormap?

Dear all matplotlib users,

I have a user case that, let’s say I have three series data: x,y,z.

I would like to make a scatter plot using (x,y) as coordinates and z as the color of scatter points, using cmap keyword of plt.scatter. However, I would like to highlight some specific point by using a different marker (or marker size) than other points.

​A minimum example is like below:
x,y,z = np.random.randn(3,10)
plt.scatter(x,y,c=z,cmap=matplotlib.cm.jet)
plt.colorbar()​

​If I want to use a different marker or marker size for (x[5],y[5],z[5]), how could I do that?

The only way I can think of is to plot again for this point using plt.scatter([x[5],y[5]) but define the color by manually finding the colormap ​color corresponding to z[5]. However this is quite tedious. Is there a better way?

​Thanks a lot for any help,

Regards,

Chao​

Screen Shot 2016-07-11 at 22.15.04.png

···

please visit:
http://www.globalcarbonatlas.org/


Chao YUE

postdoc at LSCE

CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
Tel: 33 1 69 08 41 87


OK, after posting I realize I can pass a vector to the ‘s’ keyword in plt.scatter to set the marker size, like s=[20,20,20,20,20,50,20,20,20,20]. How about using a different marker type? Thanks!

Regards,

Chao

···

On Mon, Jul 11, 2016 at 10:27 PM, Chao YUE <chaoyuejoy@…287…> wrote:

Dear all matplotlib users,

I have a user case that, let’s say I have three series data: x,y,z.

I would like to make a scatter plot using (x,y) as coordinates and z as the color of scatter points, using cmap keyword of plt.scatter. However, I would like to highlight some specific point by using a different marker (or marker size) than other points.

​A minimum example is like below:
x,y,z = np.random.randn(3,10)
plt.scatter(x,y,c=z,cmap=matplotlib.cm.jet)
plt.colorbar()​

​If I want to use a different marker or marker size for (x[5],y[5],z[5]), how could I do that?

The only way I can think of is to plot again for this point using plt.scatter([x[5],y[5]) but define the color by manually finding the colormap ​color corresponding to z[5]. However this is quite tedious. Is there a better way?

​Thanks a lot for any help,

Regards,

Chao​

please visit:
http://www.globalcarbonatlas.org/


Chao YUE

postdoc at LSCE

CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
Tel: 33 1 69 08 41 87


please visit:
http://www.globalcarbonatlas.org/


Chao YUE

postdoc at LSCE

CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
Tel: 33 1 69 08 41 87


scatter does not (currently) support multiple markers in a single call. You will have to do the group-by operation and call scatter is a loop.

If you define your cmap and norm outside of scatter, you can pass the same instances into both calls to scatter to have mpl take care of that level of mapping for you.

Tom

···

On Mon, Jul 11, 2016 at 10:27 PM, Chao YUE <chaoyuejoy@…287…> wrote:

Dear all matplotlib users,

I have a user case that, let’s say I have three series data: x,y,z.

I would like to make a scatter plot using (x,y) as coordinates and z as the color of scatter points, using cmap keyword of plt.scatter. However, I would like to highlight some specific point by using a different marker (or marker size) than other points.

​A minimum example is like below:
x,y,z = np.random.randn(3,10)
plt.scatter(x,y,c=z,cmap=matplotlib.cm.jet)
plt.colorbar()​

​If I want to use a different marker or marker size for (x[5],y[5],z[5]), how could I do that?

The only way I can think of is to plot again for this point using plt.scatter([x[5],y[5]) but define the color by manually finding the colormap ​color corresponding to z[5]. However this is quite tedious. Is there a better way?

​Thanks a lot for any help,

Regards,

Chao​

please visit:
http://www.globalcarbonatlas.org/


Chao YUE

postdoc at LSCE

CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
Tel: 33 1 69 08 41 87



please visit:
http://www.globalcarbonatlas.org/


Chao YUE

postdoc at LSCE

CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
Tel: 33 1 69 08 41 87