Title in maths symbol and title as legend on each plot on different locations.

2 ビュー (過去 30 日間)
Please:
  1. How can I make a title as legend on each of my plot on the different location apart from the general title?
  2. How can I print the greek letter "xi" as maths symbol. I tried title(sprintf('L = %i, \xi = %i', L(i), xi(i))) but couldn't work. Is giving me "\xi" insteads of the maths symbol ξ. I also wants the 0.02 to appear as it is not -2.000000e-02.
%% initialization
clear
clc
close all
%% Set up the data (just enough to need a large legend and to show variety)
t = linspace(0, 1, 11);
x = linspace(0, 1, 100)';
L = [6 2 3 7];
xi = [0, -0.02, -0.2, -0.5];
%% Start plotting
% Use an extra two plots spaces in subplot where the legend will go
figind = [1 2 4 5]; % locations where we actually want to plot data
figure(1)
for i=1:length(L)
subplot(2, 3, figind(i))
A = xi(i) ./ (1 + exp(-xi(i)*t.*x)); % the data to plot
plot(x, A)
xlabel('x')
ylabel('y')
title(sprintf('L = %i, \xi = %i', L(i), xi(i)))
end
Warning: Valid hexadecimal digits are 0-9 and A-F.
Warning: Valid hexadecimal digits are 0-9 and A-F.
Warning: Valid hexadecimal digits are 0-9 and A-F.
Warning: Valid hexadecimal digits are 0-9 and A-F.
subplot (2, 3, [3 6])
plot(x, nan)
legend(sprintfc('t = %0.2f', t), 'Location', 'west');
axis off

採用された回答

Alan Stevens
Alan Stevens 2022 年 11 月 16 日
More like this?
%% Set up the data (just enough to need a large legend and to show variety)
t = linspace(0, 1, 11);
x = linspace(0, 1, 100)';
L = [6 2 3 7];
xi = [0, -0.02, -0.2, -0.5];
%% Start plotting
% Use an extra two plots spaces in subplot where the legend will go
figind = [1 2 4 5]; % locations where we actually want to plot data
figure(1)
for i=1:length(L)
subplot(2, 3, figind(i))
A = xi(i) ./ (1 + exp(-xi(i)*t.*x)); % the data to plot
plot(x, A)
xlabel('x')
ylabel('y')
title(['L = ', int2str(L(i)), ' \xi = ', num2str(round(xi(i),2))])
end
subplot (2, 3, [3 6])
plot(x, nan)
legend(sprintfc('t = %0.2f', t), 'Location', 'west');
axis off
  2 件のコメント
University Glasgow
University Glasgow 2022 年 11 月 16 日
編集済み: University Glasgow 2022 年 11 月 16 日
Thank you for this. Please how can make the legend for t to appear at the bottom or top?
Alan Stevens
Alan Stevens 2022 年 11 月 17 日
I don't understand what it is you are asking for.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by