Change marker colour of pzplot
Show older comments
Hello everyone
I'm trying to change the marker color in the pzplot graph. I'm using version 2024b (edit:) and a LiveScript.
Apparently the code below works for a regular script, but doesn't work in a LiveScript. Maybe this is a rendering bug?
Apparently, in this version, a new object(?) called "PZPlot Properties" was introduced, which is great.
Using this new object, I can easily change the size and line thickness of all markers. But I can also only change the colour of all markers. I'd like to change the colours of the markers for the poles and zeros separately.
I tried using the "findobj" method and found, that the PZPlot apparently consists of two Scatter-Plots called "PZPoleScatter" and "PZZeroScatter", and I tried changing the color of the markers in those Scatter plots, but this does not seem to have an effect on the markers.
When I change the colour of the markers using the PZPlot properties Object, I see the color definition of the markers in both scatter plots change, and I can also see that the colours change if I directly access the properties and change the colour, but the plot isn't drawn with those correct colors.
I tried using refresh after changing the values, but that doesn't have any effect either.
See my code below:
s = tf('s');
f = (1 + 1/s)
pzp = pzplot(f);
% See https://ch.mathworks.com/help/ident/ref/controllib.chart.pzplot-properties.html for new PZPlot-properties object
pzp.Responses.MarkerSize = 10;
pzp.Responses.LineWidth = 2;
%pzp.Responses.Color = 'green'; % Changes colour of all markers
oPole = findobj(gca, 'Tag', 'PZPoleScatter');
oPole.MarkerEdgeColor = 'red';
oZero = findobj(gca, 'Tag', 'PZZeroScatter');
oZero.MarkerEdgeColor = 'blue';
rsp = findobj(gca, 'Tag', 'PZPoleScatter'); % read object again to see if properties got changed correctly
I also found the following two topics, but they do not work anymore as there is no "Line" child in the PZPlot object.
4 Comments
'I tried using the "findobj" method and ... I tried changing the color of the markers in those Scatter plots, but this does not seem to have an effect on the markers.'
That seems to work when run here (see below - all markers are of size 10 and linewidth 2, with the pole marker red and the zero marker blue).
s = tf('s');
f = 1 + 1/s;
pzp = pzplot(f);
pzp.Responses.MarkerSize = 10;
pzp.Responses.LineWidth = 2;
oPole = findobj(gca, 'Tag', 'PZPoleScatter');
oPole.MarkerEdgeColor = 'red';
oZero = findobj(gca, 'Tag', 'PZZeroScatter');
oZero.MarkerEdgeColor = 'blue';
Voss
on 27 Jan 2025
"Could you maybe test if the code also doesn't work for you in a LiveScript?"
Unfortunately, my only option to run the code is here in the Answers forum because I don't have a license for any toolbox containing pzplot.
Jan
on 27 Jan 2025
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!
