Giving different colors in skyplot when default colors repeat

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

 Respuesta aceptada

Voss
Voss el 22 de Abr. de 2022
Editada: Voss el 22 de Abr. de 2022
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 comentarios

Thank you - that was cool!
Also wondering whether it is possible to give a label to each of those satellites shown as different colors when I have a track/trajectory of the satellite in the skyplot. I could use:
skyplot(azimuth, elevation,prn, GroupData=categorical(g))
where prn could be used as the label but if there are multiple points (i.e. a track) for a particular satellite then the prn number would repeat throughout which makes the skyplot look messy. Any way to just have the prn number once instead of repeating?
Thank you
Voss
Voss el 22 de Abr. de 2022
Editada: Voss el 22 de Abr. de 2022
You're welcome!
I imagine you can use empty labels after the first one for each satellite. Maybe something like this:
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);
skyplot(azimuth(:), elevation(:), prn(:), GroupData=g(:))
% legend() % don't need the legend if you have labels
colororder(turbo(n_sat))
Thank you. This works great. I however tried to reduce the size of the color dots using:
skyplot(azimuth(:), elevation(:), prn(:), MarkerSize=10, GroupData=g(:))
but that also reduces the fontsize of the text. Any way to only reduce the size of the dots and not the text?
Voss
Voss el 22 de Abr. de 2022
Editada: Voss el 22 de Abr. de 2022
Throw in a LabelFontSize too:
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);
skyplot(azimuth(:), elevation(:), prn(:), MarkerSize=10, LabelFontSize=12, GroupData=g(:))
% legend() % don't need the legend if you have labels
colororder(turbo(n_sat))
All the properties you might want to mess with:
Thank you much for the help. Works like charm!
You're welcome!
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
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))

Iniciar sesión para comentar.

Más respuestas (1)

Categorías

Preguntada:

el 22 de Abr. de 2022

Comentada:

el 22 de Abr. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by