Combine Plot and Scatter in Legend

12 vues (au cours des 30 derniers jours)
Théo
Théo le 25 Avr 2023
Commenté : Théo le 25 Avr 2023
Hello eveyone,
I have this graph :
In the legend I would like to display the curve and the scatter like that :
Tere is my code :
fig = figure;
set(fig, 'Units', 'Normalized', 'Position', [0.2 0.2 0.45 0.35]);
plot(B,A,"k",'LineStyle',':','linewidth',2)
hold on
s = scatter(B,A,35,'filled','diamond')
s.MarkerEdgeColor = "#BDD7EE";
s.MarkerFaceColor = "#D9D9D9";
plot(B,Abis,"k",'LineStyle','--','linewidth',1)
hold on
s2 = scatter(B,Abis,35,'filled','o')
s2.MarkerEdgeColor = "k";
s2.MarkerFaceColor = "#BDD7EE";
plot(B,MoyMatrice,"r",'LineStyle','-','linewidth',1)
hold on
scatter(B,MoyMatrice,35,'r','filled','o')
xlabel('Note subjective du broutement')
ylabel('Rating Occurence')
legend ('Run 1','Run 2','GLOBAL')
ylim ([0 maxx]) ;xlim([4 9]) %Fixer les limites d'axe
title (titre,'Interpreter','none')
ax = gca;
ax.XGrid = 'off';
ax.YGrid = 'on';
ytickformat('percentage')
text(4.1,maxy-2,txt_Moyenne,'FontSize',14)
Thanks for considering !

Réponse acceptée

chicken vector
chicken vector le 25 Avr 2023
x = 1:10;
y1 = randi(10,1,10);
y2 = randi(10,1,10);
y3 = randi(10,1,10);
figure;
hold on;
grid on;
plot(x,y1,':d',...
'LineWidth',2,...
'Color','k',...
'MarkerSize',10,...
'MarkerEdgeColor','#BDD7EE',...
'MarkerFaceColor','#D9D9D9')
plot(x,y2,'--o',...
'LineWidth',1,...
'Color','k',...
'MarkerSize',10,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','#BDD7EE')
plot(x,y3,'-o',...
'LineWidth',1,...
'Color','r',...
'MarkerSize',10,...
'MarkerEdgeColor','r',...
'MarkerFaceColor','r')
hold off;
legend('Curve 1','Curve 2','Curve 3','Location','NorthEastOutside');
Result:
  1 commentaire
Théo
Théo le 25 Avr 2023
Thanks a lot !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by