How to modify subplots to create a new subplots?

I have two figures as attached. Each figure has 3x1 subplots.
open pvc4.fig
open pac4.fig
  1. In pac4.fig, how to make the TickLabels of the first two figures the same, i.e., either make it as "N, V, n/a" or "A, N, V, n/a" consistently?
  2. In pac4.fig, how to remove the thrid plot and make the figure having only two first subplots? So, I want to make it only two subplots.
  3. I want to take first two subplots of pac4.fig and take the first two subplots of pvc4.fig. So, I want to put those 4 subplots in one figure (4x4 subplots) together. The first two subplots of pac4.fig go the left side and the first two subplots of pvc4.fig go the right side of the figure.
Thank you very much,

 Accepted Answer

close all
H(1)=openfig('pac4.fig'); ax1=flip(findobj(H(1),'Type','axes'));
H(2)=openfig('pvc4.fig'); ax2=flip(findobj(H(2),'Type','axes'));
ax=[ax1(1:2);ax2(1:2)];
xt=[0.125,0.375,0.625,0.875];
xtl={'n/a','V','N','A'};
figure;
t=tiledlayout(2,2);
ax(1).Parent=t;
ax(1).Layout.Tile=1;
ax(2).Parent=t;
ax(2).Layout.Tile=3;
ax(3).Parent=t;
ax(3).Layout.Tile=2;
ax(4).Parent=t;
ax(4).Layout.Tile=4;
close(H);
for i=1:4, colorbar(ax(i),'off'); end
h=colorbar('Ticks',xt,'TickLabels',xtl); h.Layout.Tile='east';

12 Comments

Mibang
Mibang on 11 Apr 2024
Edited: Mibang on 11 Apr 2024
Great, could you also try task 2?
Task 2 has been fulfilled. The third plot is not present in the final result.
Oh, I will try using your answer.
Right, can you make each plot has own class color bar?
close all
close all
H(1)=openfig('pac4.fig');
ax1=flip(findobj(H(1),'Type','axes'));
H(2)=openfig('pvc4.fig');
ax2=flip(findobj(H(2),'Type','axes'));
ax=[ax1(1:2);ax2(1:2)];
xt=ax(3).Colorbar.Ticks;
xtl=ax(3).Colorbar.TickLabels;
cm=ax(3).Colormap;
figure;
t=tiledlayout(2,2);
ax(1).Parent=t;
ax(1).Layout.Tile=1;
ax(2).Parent=t;
ax(2).Layout.Tile=3;
ax(3).Parent=t;
ax(3).Layout.Tile=2;
ax(4).Parent=t;
ax(4).Layout.Tile=4;
close(H);
for i=1:4, colorbar(ax(i),'Ticks',xt,'TickLabels',xtl,'ColorMap',cm); end
Thank you, but, the top-left plot has non-consistent colorbar.
Could you try it and make the colorbar of the top-left plot consistent with the others?
Besides, in top-left plot, "n/a" color needs to be changed to violet. Thanks.
Matt J
Matt J on 11 Apr 2024
Edited: Matt J on 11 Apr 2024
It is very strange that you are using a colorbar to label a line plot. Why not just use legend()?
I did't intend it, but when I plotted it using plotsigroi and signalMask functions, it auto-generated it. If you use, legend(), how can you modify it? Thanks.
I edited my last version to unify the colorbars, but with legend(), it is simply,
close all
H(1)=openfig('pac4.fig');
ax1=flip(findobj(H(1),'Type','axes'));
H(2)=openfig('pvc4.fig');
ax2=flip(findobj(H(2),'Type','axes'));
ax=[ax1(1:2);ax2(1:2)];
figure;
t=tiledlayout(2,2);
ax(1).Parent=t;
ax(1).Layout.Tile=1;
ax(2).Parent=t;
ax(2).Layout.Tile=3;
ax(3).Parent=t;
ax(3).Layout.Tile=2;
ax(4).Parent=t;
ax(4).Layout.Tile=4;
close(H);
for i=1:4, colorbar(ax(i),'off');end
h=legend(["", "A" ,"N","V" , "n/A"]); h.Layout.Tile='South'; h.Orientation='horizontal';
Great, effort, but;
  1. Top-left: "n/a" is shown by yellow color. "n/a" needs to be shown by violet color as the other plots.
  2. All the other: "n/a" is shown by violet, which ic correct, but it shows black in your legend, which doesn't match.
Matt J
Matt J on 11 Apr 2024
Edited: Matt J on 11 Apr 2024
  1. I haven't done anything to change the line colors. That was what was in the .fig files.
  2. I fixed it, but you have an additional line in your data somewhere that is black.
Right, I think this is not possible unless I plot again with the original data with careful plan for colors.
Thank you very much for your effort and time.

Sign in to comment.

More Answers (0)

Asked:

on 10 Apr 2024

Commented:

on 11 Apr 2024

Community Treasure Hunt

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

Start Hunting!