How to plot a jet colour bar for specific values ?
17 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
KSSV
2022 年 3 月 31 日
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:
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!