How to set range in color panel manually?

I have a wide range of values, and when building as a scatter (x, y, z), the color bar showing the z axis shows a wide range of values, now I'm not interested in the lower values โ€‹โ€‹of the range. Is there a way to change the range in the color bar. I have the next part of my plot code, I also intend to build a log chart. E.g. I want to set the range in my log chart to 14 to the maximum value.

I want some values โ€‹โ€‹not to be displayed at all. so the color bar has a limited range, say from 14 to the maximum. It currently shows from 9 to the maximum in a logarithmic chart.

scatter(x(1:end-1), y(1:end-1), 5, gnd); title('G plot (m^-^2)'); colorbar('eastoutside'); xlabel(' X-axis (microns)'); ylabel('Y-axis (microns)'); figure; log_g=log10(gnd); scatter(x(1:end-1), y(1:end-1), 5,log_g); colorbar('eastoutside'); xlabel(' X-axis (microns)'); ylabel('Y-axis (microns)'); title('G Density, log plot (m^-^2)'); 
+6
source share
3 answers

I believe caxis is the team you are looking for. Using:

 caxis([minValue maxValue]) 

Using caxis like this, all values โ€‹โ€‹outside the range [minValue maxValue] will be colored with the lowest or highest value in the color palette, respectively.

Since colorbar and friends use colormap , you will need to adjust the current color palette if you want to adjust the number of colors used. Do it like this:

 %# get current colormap map = colormap; %# adjust for number of colors you want rows = uint16(linspace(1, size(map,1), NUM_COLORS)) ; map = map(rows, :); %# and apply the new colormap colormap(map); 

Of course, combining this with caxis is the most powerful.

If you do not want to show some values โ€‹โ€‹outside the range, this is not a task for colorbar or caxis , which is up to you - you will have to configure the data that was built so that all the values โ€‹โ€‹you do not want the graph to be NaN . This will allow Matlab to understand that you do not want to build this data:

 data( indices_to_data_not_to_plot ) = NaN; surf(x,y,data); %# or whatever you're using 
+10
source

How about this?

 % don't know why, but apparently your x and y are one value too long? x = x(1:end-1); y = y(1:end-1); % only plot values of 14 or higher scatter(x(gnd>=14), y(gnd>=14), 5, gnd(gnd>=14); 
0
source

Try the following:

 cmap = colormap; % get current colormap cmap=cmap([min max],:); % set your range here colormap(cmap); % apply new colormap colorbar(); 
0
source

Source: https://habr.com/ru/post/926901/


All Articles