Sub-plots properties

조회 수: 11(최근 30일)
SS 2020년 2월 12일
댓글: Rik 2020년 2월 12일
Hi. I have 4 MATLAB figures, using them as sub-plots I want to create a new figure. These 4 figures have a larger marker size and line width.
How can, I change/modify the line width, marker size in these subplots? I want to add labels "a, b, c, d" on the bottom left of figure. Also, I want to add some text on top left corner of each sub-plot figure.

채택된 답변

BN 2020년 2월 12일
Hello SS,
First I recommend reading this useful documentation.
In this case you want 4 subplots, so you subplots should be in subplot(2,2,1); subplot(2,2,2); subplot(2,2,3); subplot(2,2,4). as you can see the first and the second number is constant because you want 4 subplots. In fact, 2 and 2 define you want 2 in the row and 2 in the column which is four actually. the second number 1,2,3,4 adjusts the place of your subplots among each other. you can found more explanation in the document that I was mention above.
then you can consider each subplot as a plot and do what ever you previously doing in plot, like marker size changing.
In your case you can use this:
%first subplot
plot(something, 'linewidth',1); %instead of 'something' write your data. you can set linewidth
%put text box code for each subplot here (read above for more information)
%second subplot
plot(somehting, 'linewidth',1);
%third subplot
plot(somehting, 'linewidth',1);
%fourth subplot
plot(somehting, 'linewidth',1);
You can add a text box for each subplot just under the end of code for each other using the useful information in this question:
For example as you can see in this question:
plot(1:10); % create a simple line plot
a = gca; % get the current axis;
% set the width of the axis (the third value in Position)
% to be 60% of the Figure's width
a.Position(3) = 0.6;
% put the textbox at 75% of the width and
% 10% of the height of the figure
annotation('textbox', [0.75, 0.1, 0.1, 0.1], 'String', "pi value is " + pi)
  댓글 수: 2
Rik 2020년 2월 12일
Then you don't have subplots.
You can dig through the children to find the line objects, or use findobjs to do that.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Bhaskar R
Bhaskar R 2020년 2월 12일
subplot(1, 2,1), plot(1:10);
subplot(1, 2,2), plot(2*1:10);
ax = gca; % using gca fields you can do
ax.Children.Marker = 'you can set here'
  댓글 수: 1
Rik 2020년 2월 12일
A better habit would be to store the output of the subplot call to store the handle to the axis.
For directly editing the plot properties you could also consider storing the handle to the line object that the plot function returns.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by