I have a wide range of values and while plotting as a scatter(x,y,z), the colorbar showing the z axis shows a wide range of values, now I am not interested in the lower range values. Is there any method to change the range in color bar. I have the following part of my code to plot, I also intend to plot the log plot. For eg. I want to set the range in my log plot to 14 to the maximum value.
I want some values not to be displayed at all. so that the color bar has a limited range, say from 14 to maximum. At present it is showing from 9 to maximum in the log plot.
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)');
Use the vmin and vmax Parameter to Set the Range of Colorbar in Python. The vmin and vmax parameters can be used to specify the scale for mapping color values. These parameters work with the object, which uses colormaps. It can be used to control the range of the colorbar in matplotlib.
Create a colorbar with a scalar mappable object image. Initialize a variable for fontsize to change the tick size of the colorbar. Use axis tick_params() method to set the tick size of the colorbar.
You can change the color of bars in a barplot using color argument. RGB is a way of making colors. You have to to provide an amount of red, green, blue, and the transparency value to the color argument and it returns a color.
I believe that caxis
is the command you're looking for. Usage:
caxis([minValue maxValue])
Using caxis
like this, all values outside the range [minValue maxValue]
will be coloured with the lowest or highest value in the colormap, respectively.
Since colorbar
and friends use colormap
, you'll have to adjust the current colormap if you want to adjust the number of colors used. Do this like so:
%# 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 don't want to show some values outside of range, that's not a job for colorbar
or caxis
, that's up to you -- you'll have to adjust the data that's plotted so that all values you don't want plotted are NaN
. Doing so will make Matlab understand that you don't want to plot these data:
data( indices_to_data_not_to_plot ) = NaN;
surf(x,y,data); %# or whatever you're using
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With