Creating a white background behind a subplot that is placed over another sublot
Afficher commentaires plus anciens
Hey guys,
i have produced three plots as subplots with one directly on top of another and the third, an FFT of the plot to the bottom is supposed to overlap both plots (See picture: http://oi46.tinypic.com/2927d68.jpg )
Since the axes of the FFT-plot and their labels are now placed within the other plots and kind of mixing up with them, I'm looking for a solution to place a white background behind the FFT-plot, so the axes labels are visible more clearly. How would you do that?
Here's my code (it's maybe a bit pedestrian but it does its job)
h=figure;
Ticksh1 = [-0.5e-4 0 0.5e-4];
Ticksh2 = [-0.6e-5 -0.4e-5 -0.2e-5 0 0.2e-5 0.4e-5 0.6e-5 0.8e-5];
Xticks = [-2 0 2 4 6 8 10 12];
Achsenh1 = [-3.3 12.5 -1e-4 1e-4];
Achsenh2 = [-3.3 12.5 -0.7e-5 0.9e-5];
Labelsh2 = [-0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08];
set(h,'units','centimeters');
set(h,'position',[5 5 12 12]);
set(h,'PaperSize',[14 14]);
set(h,'PaperPositionMode','auto');
h2=subplot(2,2,1);
plot(rand(1,10), rand(1,10),'.r','markersize',.5)
axis xy;
box on;
axis(h2,Achsenh2);
set(gca,'YTick',Ticksh2);
set(gca,'XTick',Xticks);
set(gca,'YTickLabel',Labelsh2);
set(gca,'fontsize',8,'fontname','Helvetica', 'XMinorTick','on','YMinorTick','on');
grid
h1=subplot(2,2,2);
plot(rand(1,10), rand(1,10),'.r','markersize',0.5);
set(gca,'YTick',Ticksh1);
set(gca,'XTickLabel',[]);
set(gca,'XTick',Xticks);
set(gca,'fontsize',8,'fontname','Helvetica', 'XMinorTick','on','YMinorTick','on');
axis(h1,Achsenh1);
grid
h3=subplot(2,2,[3 4]);
box on
plot(rand(1,10),rand(1,10),'markersize',5,'Marker','.','MarkerEdgecolor','k');
end
hold off
xlabel('\nu in THz','FontSize',11)
ylabel('|Y(\nu)|','FontSize',11)
axis xy;
axis(h3,[0 5 0 1.8e-6]);
text(2.5,1.8e-6,'\bfFFT','FontSize',13, 'BackgroundColor',[1 1 1]);
set(h2,'position',[0.15 0.1 0.75 0.5]);
set(h1,'position',[0.15 0.6 0.75 0.24]);
set(h3,'position',[0.55 0.5 0.35 0.2]);placed
xlabel(h2,'Delay in ps','FontSize',11);
ylabel(h1,'\DeltaR/R_0','FontSize',11);
ylabel(h2,'\DeltaR/R_0','FontSize',11);
grid
print(gcf, 'plot', '-depsc');
EDIT: Made code executable with rand(1,10) as plot variables
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!