how to change line colors in bodes, nichols, nyquist, etc

36 次查看(过去 30 天)
I've been trying to change the line colors when plotting 30+ systems and it seems like the routines creating the plots in the title are not using the color order in the gca/axis. When I've accessed the handle through following code it seems like there are still a fixed number of colors available, ~6-7
h.Responses(n).Style.Colors{1} =
h.Responses(n).Style.setstyle
When I start adding more lines and setting the colors then all the previous linecolors are also changed, like a circular buffer of some sort is in use. I've just been trying to a jet and it works for 7 or so lines & colors, but does not work for a number like 30+ unique systems

回答(2 个)

Image Analyst
Image Analyst 2021-7-14
See attached demo for how to change the default color order.
  2 个评论
Stephen Reiman
Stephen Reiman 2021-7-14
编辑:Stephen Reiman 2021-7-14
Line 79 from the demo did appear to work with lines added using the plot function
Line 79: set(gca, 'ColorOrder', newDefaultColors, 'NextPlot', 'replacechildren');
As stated, observed behaviors in nicholsplot, bodeplot, & nyquistplot are that they are not using the same color order.
The code included in the original question implents the solution from the link below, but broke down as the number of systems being drawn increased.
https://www.mathworks.com/matlabcentral/answers/151514-how-can-i-define-my-own-colororder-for-a-bodeplot
Image Analyst
Image Analyst 2021-7-14
Sometimes you can edit the code and change things. Other times, not, as the m-file calls a mex function.
>> edit nicholsplot.m
See if that gets you anywhere.

请先登录,再进行评论。


Paul
Paul 2021-7-15
I tested stepplot and bodeplot and am seeing the same thing as you, i.e., if more than 7 responses, then multiple responses are linked together somehow and share the same color. Don't know why it's set up that way and couldn't find a way to change it, but as far as I can tell it's all undocumented behavior so can't really expect anything.
As a work around, you can use plain old bode() and step() and get the handles to the lines and change colors at will, so it seems to me.
  1 个评论
Stephen Reiman
Stephen Reiman 2021-7-15
编辑:Stephen Reiman 2021-7-15
After poking around at the m-files as recommended I did settle on a solution.
I ended up implementing a color change per my original post for the 1st system and using the returns from bode, nichols, & nyquist with "line" for additional ones. Memory usage went down substantially.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Plot Customization 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by