Creating text for subcaptions in subplot figure

조회 수: 8 (최근 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 CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by