How can i make the legend as shown in the figure attached?
3 ビュー (過去 30 日間)
古いコメントを表示
I need to make the legend as shown in the figure as below:
I need to show markers for exp., solid line for Sim for same case as shown in figure.

0 件のコメント
採用された回答
Austin M. Weber
2024 年 1 月 28 日
Generating some example data (use your actual data instead of this)
% Generating fake experimental data since I don't have yours
x_exp = linspace(0,12,20);
toyoura_exp = x_exp .^(1/3);
MH_exp = x_exp .^(1/3) .* 3;
CDH_exp = x_exp .^(1/3) .* 2;
% Generating fake simulation data since I don't have yours
x_sim = linspace(0,15,100);
toyoura_sim = x_sim .^(1/3);
MH_sim = x_sim .^(1/3) .* 3;
CDH_sim = x_sim .^(1/3) .* 2;
Plot the data:
figure
scatter(x_exp,toyoura_exp,'sk')
hold on
scatter(x_exp,MH_exp,'^r')
scatter(x_exp,CDH_exp,'ob')
plot(x_sim,toyoura_sim,'-k','LineWidth',1)
plot(x_sim,MH_sim,'-r','LineWidth',1)
plot(x_sim,CDH_sim,'-b','LineWidth',1)
hold off
Edit the appearance of the axes to match example figure
xlim([0,15]),ylim([0,10]), axis square, box on
ylabel('Deviator Stress {\itq} [MPa]')
xlabel('Axial Strain [%]')
set(gca,'XMinorTick','on','YMinorTick','on')
Create a legend with two columns:
legend_names = {'Toyoura sand (S_r^H=0.0%), Exp.,','MH (S_r^H=48.0%), Exp.,','CDH (S_r^H=49.0%), Exp.,',...
'Sim.','Sim.','Sim.'};
L=legend(legend_names);
L.NumColumns=2;
L.Location='north';
Add the additional text:
hold on
text(0.5,7,'Experiment: Miyazaki {\it et al.} (2016)')
text(10,0.5,'p_0^/ = 1.0 MPa')
hold off
Repeat the above steps for your second plot.
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2024 年 1 月 28 日
The trick would be to configure two columns for the legend... and configure the legend entries for the first three legends to end in commas.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!