Combine Plot and Scatter in Legend

26 ビュー (過去 30 日間)
Théo
Théo 2023 年 4 月 25 日
コメント済み: Théo 2023 年 4 月 25 日
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 !

採用された回答

chicken vector
chicken vector 2023 年 4 月 25 日
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 件のコメント
Théo
Théo 2023 年 4 月 25 日
Thanks a lot !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by