Sub-plots properties
23 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposta accettata
BN
il 12 Feb 2020
Hello SS,
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:
figure;
%first subplot
subplot(2,2,1);
plot(something, 'linewidth',1); %instead of 'something' write your data. you can set linewidth
xlabel('something')
ylabel('something')
%put text box code for each subplot here (read above for more information)
%second subplot
subplot(2,2,2);
plot(somehting, 'linewidth',1);
xlabel('something')
ylabel('something')
%third subplot
subplot(2,2,3);
plot(somehting, 'linewidth',1);
xlabel('something')
ylabel('something')
%fourth subplot
subplot(2,2,4);
plot(somehting, 'linewidth',1);
xlabel('something')
ylabel('something')
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:
figure;
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 Commenti
Rik
il 12 Feb 2020
Then you don't have subplots.
You can dig through the children to find the line objects, or use findobjs to do that.
Più risposte (1)
Bhaskar R
il 12 Feb 2020
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 Commento
Rik
il 12 Feb 2020
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.
Vedere anche
Categorie
Scopri di più su Subplots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!