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

조회 수: 3 (최근 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