Ploting multiple traces with different colors. plot(x,y, 'color', 'red') not working

6 次查看(过去 30 天)
I am reading data from a folder with 9 s2p files that have S21 data that I am trying to plot. There are 3 temperatures I measured at and it is noted in the file name and is successfully sorted out. My issue is I want each temperature to have it's own color on the plot. My error is only present when I try to add color. I get the error "Error using rfdata.data/calculate>checkopcondition (line 1008) red is not a valid parameter or format."
the variable "data" is a single data variable and I am using the plot to just plot the S21 parameters
Why is the color not working?
for i=1:length(fileNames)
name = fileNames{i};
data = read(rfdata.data,name);
%custom adjustments for temperature
temp50 = '50C';
temp75 = '75C';
temp100 = '100C';
if contains(name,temp50)
legend_name_real(i) = strcat(legend_name_real(i), temp50);
plot(data, 's21', 'db','color', 'yellow');
elseif contains(name,temp75)
legend_name_real(i) = strcat(legend_name_real(i), temp75);
plot(data, 's21', 'db','color', 'orange');
elseif contains(name,temp100)
legend_name_real(i) = strcat(legend_name_real(i), temp100);
plot(data, 's21', 'db','color','red');
else
legend_name_real(i) = strcat(legend_name_real(i), ' room temp');
plot(data, 's21', 'db','color', 'green');
end
title('Title name');
hold on
end
legend(legend_name_real);
legend

采纳的回答

Voss
Voss 2024-4-9
'color' is not a valid parameter to pass to rfdata.plot
Try setting the color after plotting, as in:
h = plot(data, 's21', 'db');
h.Color = 'red';
Also, note that 'orange' is not one of the special named colors you can use; you'll have to specify it as an RGB triplet, e.g.,
h.Color = [1 0.5 0]; % orange

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by