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:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by