Help getting clim (caxis) to work as I want
Mostra commenti meno recenti
Hello,
I am using a graph to show some lines (defined by their start and end points) each of which has a color depending on a value stored in a vector. The values in that vector can potentially vary from 0 to 1, but actually the minimum value in the dataset I am using for my tests is 0.55 approximately.
If I don't specify the limits for the colorbar it automatically adapts to the 0.55-1 range of my dataset, which is fine, but if I set it to [0 1] what it does is assigning the lowest color value to all values below 0.55, so the color scale between 0.55 and 1 doesn't change. What I want is to have that colorbar gradually varying from 0 to 1, no matter what actual range I have in my dataset.
This is the code I am using:
figure;hold on;
% Drawing the graph. startv is the vector containing three columns with the start points of each line and endv contains the end points.
% ColorVector is a vector contaning a value in the range 0-1 per line
for i=1:length(ColorVector)
patch([startv(i,1);endv(i,1)],[startv(i,2);endv(i,2)],[startv(i,3);endv(i,3)], [ColorVector(i);ColorVector(i)],'EdgeColor','interp');
end
% Adjusting the colormap and colorbar
colormap jet;
clim="Manual";
clim=[0 1];
%caxis=[0 1];
c=colorbar;
% c.LimitsMode="manual";
% map=colormap;
c.Limits=[0 1]; %kolore barraren mugak finkatu
view(3)
This is what I get:

As you can see in my commented code, I have tried several things, including setting the colormap limits (using clim since I am using Matlab 2022a, but also caxis in case clim wasn't working properly) and the colorbar limits. I have tried to follow the clim documentation and examples (https://www.mathworks.com/help/matlab/ref/clim.html?searchHighlight=clim&s_tid=srchtitle_clim_1) and they seem clear to me but I am not able to adjust the colorbar as I intend.
Thanks in advance for your help.
Julen
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Orange in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!