Giving different colors in skyplot when default colors repeat

7 次查看(过去 30 天)
Hi all,
I was trying to get a skyplot for 15 different satellites but it seems that the colors in the legend is repeating. I actually wanted to give unique colors for the individual satellites, and tried the following:
initialColorOrder = get(gca,'ColorOrder') % to display the initial colors
newDefaultColors = copper(15)
set(gca, 'ColorOrder', newDefaultColors, 'NextPlot', 'replacechildren')
newColorOrder = get(gca,'ColorOrder') % to display the new colors
skyplot(azimuth, elevation, GroupData=categorical(g))
legend()
Even though I could see that newColorOrder now contains 15 different colors its not reflected in the skyplot which still is using the initial default colors. Any suggestion why that is happening?
I also tried the following:
skyplot(azimuth, elevation, GroupData=categorical(g))
legend()
colororder(parula(15))
Even though it appears to give what I desired, the individual colors are most of the times indistinguishable ''visually''.
Thanks

采纳的回答

Voss
Voss 2022-4-22
编辑:Voss 2022-4-22
When you set the ColorOrder of gca before calling skyplot, you are setting properties of the current axes, whatever it is. Then skyplot makes a new axes, so whatever you did to the old current axes is irrelevant for skyplot.
When you set the ColorOrder of gca after calling skyplot, then the current axes is the axes that skyplot created, so it works.
Now you just have to change parula(15) to a set of colors you prefer.
azimuth = 360*rand(1,15);
elevation = 90*rand(1,15);
g = rand(1,15);
skyplot(azimuth, elevation, GroupData=categorical(g))
legend()
colororder(turbo(15))
  9 个评论
Mathan
Mathan 2022-4-22
Sorry but also wondering whether its possible to increase the markersize of just one satellite (like can I make the markers of just one satellite bigger than the rest)?
Thanks
Voss
Voss 2022-4-22
n_sat = 15; % number of satellites
n_pts = 5; % number of points per satellite
% trying to make some random yet coherent tracks for the satellites here
% (obviously you can just use your azimuth and elevation data)
azimuth = mod(cumsum([360*rand(1,n_sat); 5*rand(n_pts-1,n_sat)],1),360);
elevation = mod(cumsum([90*rand(1,n_sat); 10*rand(n_pts-1,n_sat)],1),90);
% repeat the same groups 1-15 for all n_pts points
g = categorical(repmat(1:n_sat,n_pts,1));
% construct labels
prn = repmat({''},n_pts,n_sat);
% only first row is non-empty
prn(1,:) = sprintfc('Sat. %d',1:n_sat);
% construct marker sizes
ms = 10*ones(n_pts,n_sat);
% make markers for satellite 1 larger than the others:
ms(:,1) = 50;
skyplot(azimuth(:), elevation(:), prn(:), MarkerSize=ms(:), LabelFontSize=12, GroupData=g(:))
% legend() % don't need the legend if you have labels
colororder(turbo(n_sat))
Note that MarkerSize is a vector with one element per data point, so you can have them vary however you want:
% construct marker sizes
ms = (90-elevation).^1.5.*abs(cosd(azimuth));
skyplot(azimuth(:), elevation(:), prn(:), MarkerSize=ms(:), LabelFontSize=12, GroupData=g(:))
% legend() % don't need the legend if you have labels
colororder(turbo(n_sat))

请先登录,再进行评论。

更多回答(1 个)

Mathan
Mathan 2022-4-22
Thank you once again.

类别

Help CenterFile Exchange 中查找有关 Scenario Generation and Visualization 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by