如何修改MATLAB色条上的颜色

时间:2012-12-12 03:09:55

标签: matlab colors plot colorbar

我正在绘制一些卫星的方位角和仰角,每个轨迹的颜色代表S4指数,从低(蓝色)到高(红色)。但是,我希望能够格式化颜色和相应的值,以便可以实际区分闪烁的更多低效果。这是因为闪烁的高端(红色)仅显示一个或两个点。这是轨迹和代码的图片。

satellite trajectory showing color coded scintillation

clc; close all; clear all
load combo_323_full
circular_plot
x = [];
y = [];
for s = 1:samples       
  % plot each satellite location for that sample
  for sv = 1:sats
    % check if positive or negative elevation
    if (elevation((s - 1) * sats + sv) < 0)
      elNeg = 1;
    else
      elNeg = 0;
    end
    % convert to plottable cartesian coordinates
    el = elevation((s - 1) * sats + sv);
    az = azimuth((s - 1) * sats + sv);
    x = [x;(pi/2-abs(el))/(pi/2).*cos(az-pi/2)];
    y = [y;-1*(pi/2-abs(el))/(pi/2).*sin(az-pi/2)];
    % check for final sample
%     if (s == samples)
%       plot(x,y,'r*');
%       text(x,y+.07,int2str(SVs(sv)), ...
%            'horizontalalignment', ...
%            'center','color','r');
%     else
      % check for +/- elevation
%       if (elNeg == 0)
%         plot(x,y,'.','color',rgb('DarkBlue'));
%       else
%         plot(x,y,'g.');
% %       end
%     end
  end
end
z = combo(:,5);
for j = 1:10
%     hold on
%     circular_plot
lRef = length(x);
l1 = floor(lRef*(1/100));
l2 = floor(l1*j);
x_time = x(1:l2);
y_time = y(1:l2);
zr = z(1:l2);

navConstants;

% find out from 'plotMat' if plotting satellite locations or trajectories in
% addition determine how many satellites are being tracked and how many
% samples for each satellite (# samples / satellite must always be equal)
gpsTime = combo(1,2);
i = 1;
t = gpsTime;
while ((i ~= size(combo,1)) & (t == gpsTime))
  i = i + 1;
  t = combo(i,2);
end
if (t == gpsTime)
  sats = i;
else
  sats = i - 1;
end;
samples = size(combo,1) / sats;
SVs = combo(1:sats,1);
elevation = combo(:,20).*pi/180;
azimuth = combo(:,19).*pi/180;
% initialize polar - plotting area
figure(j);
axis([-1.4 1.4 -1.1 1.1]);
axis('off');
axis(axis);
hold on;
% plot circular axis and labels
th = 0:pi/50:2*pi;
x_c = [ cos(th) .67.*cos(th) .33.*cos(th) ];
y_c = [ sin(th) .67.*sin(th) .33.*sin(th) ];
plot(x_c,y_c,'color','w');
text(1.1,0,'90','horizontalalignment','center');
text(0,1.1,'0','horizontalalignment','center');
text(-1.1,0,'270','horizontalalignment','center');
text(0,-1.1,'180','horizontalalignment','center'); 
% plot spoke axis and labels
th = (1:6)*2*pi/12;
x_c = [ -cos(th); cos(th) ];
y_c = [ -sin(th); sin(th) ];
plot(x_c,y_c,'color','w');
text(-.46,.93,'0','horizontalalignment','center');
text(-.30,.66,'30','horizontalalignment','center');
text(-.13,.36,'60','horizontalalignment','center');
text(.04,.07,'90','horizontalalignment','center');

scatter(x_time,y_time,3,zr)
colorbar
axis equal
end

1 个答案:

答案 0 :(得分:4)

你可以制作自己的colormap,它只是一个N×3矩阵,其中的列分别是红色,绿色和蓝色。

默认色图是jet。如果您输入例如

>>> jet(16)

你将获得一个16乘3的矩阵,你可以看到它是如何制作的。

然后使用colormap(your_own_colormap)进行更改。