Setting different line colors according to the ColorOrder array using pzplot in subplots
Show older comments
I am running a for-loop where I form an ss()-object at each iteration. I then use subplot to show the pzplot of each system. This is working fine with the following:
for k = 1:4
...
figure(1)
subplot(2,2,k);
pzplot(SYS(:,:,k));
sgrid
end
Of course, all the subplots use the standard blue color. I would like them to progress through the ax.ColorOrder array as if I was plotting everything in one plot using hold. However, the only way I have successfully managed to change the color of a pzplot is using:
pzplot(SYS(:,:,k),'r');
I don't know how to switch from the 'r'-syntax to the [1 0 0] which is in the ax.ColorOrder array.
Any help is appreciated, thanks!
Answers (2)
Image Analyst
on 3 Sep 2015
0 votes
See my attached color order demo. It does that.

5 Comments
Image Analyst
on 3 Sep 2015
I don't use pzplot. I use plot() because it gives you the most control over how you want your plots to look. In plot() you can specify the line color with the color option and any 3 element array of RGB value in the range 0-1, like
plot(x, y, 'Color', [0.1, 0.25, 0.8]);
or whatever color you want.
Jesper
on 3 Sep 2015
Image Analyst
on 3 Sep 2015
Sorry. If anyone else uses pzplot, then hopefully they'll see your question and give you an answer that works. I'm not sure how commonly used it is though, but good luck.
Jesper
on 4 Sep 2015
10 years later, you can now do this via the pzplot chart API.
Here is a demo showing how you can set a custom color order for a single pzplot:
h = pzplot(rss(3),rss(3),rss(3),rss(3)); %Create chart with 4 systems
h.ColorOrder = [1 0 0;0 1 0;0 0 1]; %repeat red, green, blue (4th system is also red)
h.Legend.Visible = "on"; %Show legend
Here is a demo showing how you can set the series index value across mulitple pzplots:
f = figure(); %Create new figure
t = tiledlayout(f,"flow"); %Create a flow layout
for ii = 1:4
h = pzplot(t,rss(3)); %Create new chart in layout
h.Layout.Tile = ii; %Place in new tile
h.Responses(1).SeriesIndex = ii; %Assign response next series index
end
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
