Legend wont display lines properly in figure window

1 回表示 (過去 30 日間)
Ethyn Smith
Ethyn Smith 2022 年 4 月 17 日
コメント済み: VBBV 2022 年 4 月 17 日
Hi im hoping someone can help please. Im using the following code to plot a graph with multiple data sets and include a legend however when opening in the figure window the legend displays as below and i cannot figure out how to solve it. it displays fine in the live editor but in wont in the figure window. thanks in advance :)
figure
plot(Time_Bundle1,y1,'r--',time_2,y2,'b--',time_3,y3,'k--', ...
time_4,y4,'m--',time_5,y5,'g--',time_6,y6,'c--')
lgd = legend({'Bundle','30% Opening','50% Opening', ...
'65% Opening','85% Opening','100% Opening'});
title(lgd,'Experiment','FontSize',10)
grid on
grid minor
title('Processed Results using logarithmic deterioration')
% xlim([0 250])
ylim([-7 0.5])
xlabel('Time (s)')
ylabel('log((T - T_{a})/(T_{m} - T_{a}))')

回答 (1 件)

VBBV
VBBV 2022 年 4 月 17 日
lgd = legend('Bundle','30% Opening','50% Opening', ...
'65% Opening','85% Opening','100% Opening');
Use without a { }
  2 件のコメント
Ethyn Smith
Ethyn Smith 2022 年 4 月 17 日
Ive tried that but it just wont work. thank you anyway
VBBV
VBBV 2022 年 4 月 17 日
ax = plot(Time_Bundle1,y1,'r--',time_2,y2,'b--',time_3,y3,'k--', ...
time_4,y4,'m--',time_5,y5,'g--',time_6,y6,'c--')
lgd = legend(ax,{'Bundle','30% Opening','50% Opening', ...
'65% Opening','85% Opening','100% Opening'});
Check using a function handle to plot function

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

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by