Bug using SmithChart function to plot multiple curves with different colors

5 次查看(过去 30 天)
I'm using matkab 2019b. I'm tryng to plot multiple curves (lines) on a smith chart plot.
For some reasons I am not able to have more than 7 distinc colors when using the function smithplot.
When I try chaning the 8th curve color uing the interactive figure GUI, changing the 8th curve color also changes the 1st curve color.
I have tried inputting the curve colors manually, but same thing, the 8th curve color overwrites the first curve color and I end up with the 1st and 8th curves having the same color.
Any suggestions on how to solve the issue or maybe a work around?

回答(1 个)

Shubham
Shubham 2023-3-8
Hi Ahmed,
One possible solution is to manually define the colors for each curve using the 'ColorOrder' property of the axes object. This property specifies the default order of colors used for plotting lines.
Here's an example code that demonstrates how to do this:
% Create some sample data
s = smithplot;
z = linspace(0.1, 1, 10);
y = rand(size(z)) + 1i*rand(size(z));
% Define the colors for each curve
colors = lines(10); % or any other colormap you prefer
ax = gca;
ax.ColorOrder = colors;
% Plot the lines
for i = 1:numel(z)
plot(s, z(i), y(i), 'LineWidth', 2);
end
In this example, we first create a smith chart using the smithplot function. Then we define some sample data for 10 curves. We also define the colors for each curve using the lines colormap and set the ColorOrder property of the current axes object to these colors. Finally, we plot each curve using a loop and the plot function.
By setting the ColorOrder property of the axes object, we ensure that each curve will be plotted with a distinct color. This should solve the issue of overwriting colors when plotting more than 7 curves.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by