How to plot a jet colour bar for specific values ?
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone,
My script works perfectly, but I unable to set the color bar as jet. May someone suggets a possible way out. Thanks
Scripts is as below:
lear all
clc
X = load('PDS_case.csv'); % input data
C_sort = sortrows(X,5);
Tri = C_sort(1:86,:);
data1 = sortrows(Tri,7);
PDS=(data1(:,7))';
data2=data1(:,8:66);
data4=data2';
Y=data4(:,1:86);
X=Y';
UU=[2e-8, 4e-8, 6e-8, 8e-8, 1e-7, 3e-7]; % these values linked with each color bar, should be make a color bar
r{1}=[X(1:60,:)];
r{2}=[X(61:68,:)];
r{3}=[X(69:76,:)];
r{4}=[X(77:79,:)];
r{5}=[X(80:81,:)];
r{6}=[X(82:85,:)];
figure
cm = colormap(jet(numel(r)));
cc = colorbar('vert');
set(cc,'Ticks',((1:numel(UU))/numel(UU))');
set(cc,'TickLabels',num2str(UU'));
ylabel(cc,'PDS')
hold on
for k = 1:numel(r) % ... Then, Remove The 'NaN' Elements ...
ra = r{k};
ra = ra(~isnan(ra));
[f ,x ] = ecdf(ra);
[x ,ia ,ic ] = unique(x);
f = f(ia );
xx = linspace(min(x ),max(x ),100);
ff = interp1(x ,f ,xx );
ffs = smoothdata(ff , 'loess',10);
dx = mean(diff(xx ));
dfdxs = gradient(ffs )./dx ;
plot(xx , dfdxs , '-', 'linewidth', 1, 'Color',cm(k,:))
ylim([0, 8])
xlabel('R')
ylabel('Probability Density')
end
hold off
%grid
Here is what i get
Here is wnt i expect (two thing jet color bar and scale shold be like power only)
0 Kommentare
Antworten (1)
KSSV
am 31 Mär. 2022
This line:
cm = colormap(jet(numel(r)));
You are limiting the colorbar to only six colors. So you are getting the colorbar as you shown. Replace the line with:
cm = colormap(jet); % or may be you can use more number than 6, like 32 or 64..
For the second part of the question, you need to play with ticklabels. May be refer this for demo:
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!