Creating text for subcaptions in subplot figure

7 ビュー (過去 30 日間)
Guilherme Theis
Guilherme Theis 2020 年 6 月 4 日
編集済み: Rik 2020 年 6 月 4 日
Hello,
I want to use a subplot in a journal that doesn't allow multiple figures (so I need to pre-combine them). So I thought in using subplot which should be easy to create a figure with 4 different plots. The plot script is below.
clc;clear;
rng(4); % for always having same results
data1_x = sort(randi(10,1,5));
data2_x = sort(randi(10,1,5));
data3_x = sort(randi(10,1,5));
data4_x = sort(randi(10,1,5));
data1_y = sort(randi([10,30],1,5));
data2_y = sort(randi([10,30],1,5));
data3_y = sort(randi([10,30],1,5));
data4_y = sort(randi([10,30],1,5));
figure()
subplot(2,2,1)
plot(data1_x, data1_y)
legend()
subplot(2,2,2)
plot(data2_x, data2_y)
subplot(2,2,3)
plot(data3_x, data3_y)
subplot(2,2,4)
plot(data1_x, data4_y)
This generates the following plot:
And I want something as the following (but with a precise placement instead of a paint like I did now). I know I can accomplish this through annotation, but well annotation is a very unreliable function in my opinion (i.e it changes if you change the size of your picture by maximizing/restoring down).

回答 (1 件)

Rik
Rik 2020 年 6 月 4 日
編集済み: Rik 2020 年 6 月 4 日
Even for subplots you can use the title and xlabel functions. Your picture looks like you want to use xlabel.
clc;clear;
rng(4); % for always having same results
data1_x = sort(randi(10,1,5));
data2_x = sort(randi(10,1,5));
data3_x = sort(randi(10,1,5));
data4_x = sort(randi(10,1,5));
data1_y = sort(randi([10,30],1,5));
data2_y = sort(randi([10,30],1,5));
data3_y = sort(randi([10,30],1,5));
data4_y = sort(randi([10,30],1,5));
figure(1),clf(1)
subplot(2,2,1)
plot(data1_x, data1_y)
xlabel('(a)')
subplot(2,2,2)
plot(data2_x, data2_y)
xlabel('(b)')
subplot(2,2,3)
plot(data3_x, data3_y)
xlabel('(c)')
subplot(2,2,4)
plot(data1_x, data4_y)
xlabel('(d)')

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by