Azzera filtri
Azzera filtri

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

6 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Voss
Voss il 9 Apr 2024
'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

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by