Creating text for subcaptions in subplot figure
조회 수: 8 (최근 30일)
이전 댓글 표시
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).

댓글 수: 0
답변 (1개)
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)')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!