Legend issue: not all the entrties are shown.

조회 수: 1 (최근 30일)
john_arle
john_arle 2019년 4월 7일
댓글: Walter Roberson 2019년 4월 7일
Hello there,
I am having trouble with my legend.
I have single plot, and then I typed "hold on" and added a curve to my plot.
I cannot insert a correct legend though!
How is this possible?
Thank you in advance.
Cheers,
Andrea.
plot(linspace(0.03,0.3), poiseuille(linspace(0.03,0.3)),'k')
axis([0 0.3 0 12])
title('Velocity profiles for $\epsilon = 0.1$','Interpreter','latex',...
'fontweight','bold','fontsize',20)
xlabel('$r$ [m]','Interpreter','latex','fontweight','bold','fontsize',20);
ylabel('$u=u(r,t=0)$ [m/s]','Interpreter','latex',...
'fontweight','bold','fontsize',20);
leg_1 = legend('Poiseuille' );
set(leg_1,'FontSize',10);
hold on
plot(linspace(0.03,0.3), vel((1:100), 0),'color', [0.3 0.3 0.55])
leg_2 = legend( {'$\alpha = 0.1$'}, 'Interpreter','latex' );
set(leg_2,'FontSize',15);
hold on

채택된 답변

A. Sawas
A. Sawas 2019년 4월 7일
You can only add one legend to the axis. So to solve your problem put all the names in one legend call. You may modify your code to do like this:
%leg_1 = legend('Poiseuille' );
%set(leg_1,'FontSize',10);
% rest of your code
leg_2 = legend( {'Poiseuille', '$\alpha = 0.1$'}, 'Interpreter','latex' );
set(leg_2,'FontSize',15);
hold on
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 7일
Note that you will only get a single fontsize when you do this. You could include a \fontsize as part the latex code, but be aware that MATLAB might not include enough space between entries. It would probably be safer to 'Fontsize' the larger font, and \fontsize the other entries down to what they need.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by