How to skip a data set in the legend of a plot?

4 vues (au cours des 30 derniers jours)
Alfredo Scigliani
Alfredo Scigliani le 25 Avr 2022
I have 6 data sets in a plot for which I only want to show 3 in my legend, because the other 3 are just fits. If anybody can show me how to skip data sets in the legend I'd appreciate it!
This is my code (I will also attach it):
clear; clc; clf; close all;
x1 = [0.015 0.020 0.050 0.100 0.200 0.300 0.400 0.500];
y1 = [5.518E-11 7.215E-11 1.832E-10 3.824E-10 7.328E-10 1.127E-09 1.472E-09 1.831E-09];
y1_fit = [5.4986E-11 7.3391E-11 1.8408E-10 3.6907E-10 7.3998E-10 1.1116E-09 1.4836E-09 1.8560E-09];
x2 = [0.015 0.020 0.050 0.100 0.200 0.300 0.400 0.500];
y2 = [4.881E-11 7.215E-11 1.505E-10 2.299E-10 2.885E-10 5.622E-10 3.367E-10 5.284E-10];
y2_fit = [5.935E-11 7.128E-11 1.277E-10 1.986E-10 3.087E-10 3.997E-10 4.800E-10 5.533E-10];
x3 = [0.015 0.020 0.100 0.200 0.300];
y3 = [1.6010E-11 2.7611E-11 1.2114E-10 2.1066E-10 3.6957E-10];
y3_fit = [1.7010E-11 2.2611E-11 1.1114E-10 2.2066E-10 3.2957E-10];
loglog(x1, y1, 'bo', x1, y1_fit, 'b-')
hold on
loglog(x2, y2, 'ro', x2, y2_fit, 'r--')
loglog(x3, y3, 'go', x3, y3_fit, 'g--')
grid on
hold off
legend('data 1', 'skip this', 'data2', 'skip this','data 2', 'skip this')

Réponse acceptée

VBBV
VBBV le 25 Avr 2022
clear; clc; clf; close all;
x1 = [0.015 0.020 0.050 0.100 0.200 0.300 0.400 0.500];
y1 = [5.518E-11 7.215E-11 1.832E-10 3.824E-10 7.328E-10 1.127E-09 1.472E-09 1.831E-09];
y1_fit = [5.4986E-11 7.3391E-11 1.8408E-10 3.6907E-10 7.3998E-10 1.1116E-09 1.4836E-09 1.8560E-09];
x2 = [0.015 0.020 0.050 0.100 0.200 0.300 0.400 0.500];
y2 = [4.881E-11 7.215E-11 1.505E-10 2.299E-10 2.885E-10 5.622E-10 3.367E-10 5.284E-10];
y2_fit = [5.935E-11 7.128E-11 1.277E-10 1.986E-10 3.087E-10 3.997E-10 4.800E-10 5.533E-10];
x3 = [0.015 0.020 0.100 0.200 0.300];
y3 = [1.6010E-11 2.7611E-11 1.2114E-10 2.1066E-10 3.6957E-10];
y3_fit = [1.7010E-11 2.2611E-11 1.1114E-10 2.2066E-10 3.2957E-10];
loglog(x1, y1, 'bo', x1, y1_fit, 'b-')
hold on
loglog(x2, y2, 'ro', x2, y2_fit, 'r--')
loglog(x3, y3, 'go', x3, y3_fit, 'g--')
grid on
hold off
legend('data 1', '', 'data2', '','data 3', '') % put it empty
  4 commentaires
VBBV
VBBV le 25 Avr 2022
try using function handles , for data with markers having 'o'
Alfredo Scigliani
Alfredo Scigliani le 25 Avr 2022
Yes! Thank you so much!!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by