LeChat
LeChat

Reputation: 486

How to adjust the zcolor scale in a scatter plot in Matlab?

I have a data set, contained in three vectors say xx, yy and zz. I want to plot yy vs xx with the marker color face according to zz, so I use the scatter function such as:

scatter(xx,yy,50,zz,'s','filled')

Unfortunately zz has some very extreme values, so I cannot see any difference in the marker face color: all the dots are dark blue!

Is there a possibility to solve this issue? I was thinking of a possibility to impose a lower and an upper value for the color scale, so that any dot with a zz value out of the authorized range would be grey (or of the color of the closest bound)...?

Thank you for your help!

Upvotes: 1

Views: 627

Answers (1)

il_raffa
il_raffa

Reputation: 5175

You can try changing the CLim property of the axes.

This example uses the MatLab example data seamount an changes the colorscale range

  • from the original [-4250 -490]
  • to the new [-1000 -100]

Default color scale

load seamount
figure
scatter(x,y,5,z)
colorbar

Modified color scale

figure
scatter(x,y,5,z)
set(gca,'clim',[-1000 -100])
colorbar

Default color scale

enter image description here

Nodified color scale

enter image description here

Upvotes: 1

Related Questions