TightInset indeed should adjust for the text:
How to adjust figure size when using plotyy?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to adjust the figure size when using plotyy:
clc;
clear all;
t = 0:.1:4*pi;
y = sin(t);
figure(1);
set(gcf,'units','inches','renderer', 'painters');
pos = get(gcf,'pos');
set(gcf,'Units','inches',...
'Position',[pos(1) pos(2) 4 2]);
plot(t,y)
xlabel('Time(s)')
ylabel('y(t)')
title('Sin function')
legend('y=sin(t)')
axis([0 t(end) -1.5 1.5])
set(gca,...
'Units','normalized',...
'YTick',-1.5:.5:1.5,...
'XTick',0:t(end)/4:t(end),...
'FontUnits','points',...
'FontWeight','normal',...
'FontSize',9,...
'FontName','Times')
set(gca, 'Position', get(gca, 'OuterPosition') - ...
get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);
figure(2);
set(gcf,'units','inches','renderer', 'painters');
pos = get(gcf,'pos');
set(gcf,'Units','inches',...
'Position',[pos(1) pos(2) 4 2]);
[haxes,hline1,hline2]=plotyy(t,y,t,t);
ylabel(haxes(1),'sin(t)')
ylabel(haxes(2),'45degree')
xlabel(haxes(1),'Time(s)')
title('Sin function')
set(haxes,...
'Units','normalized',...
'FontUnits','points',...
'FontWeight','normal',...
'FontSize',9,...
'FontName','Times')
set(haxes(1), 'Position', get(haxes(1), 'OuterPosition') - ...
get(haxes(1), 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 0 0; 0 0 0 1]-...
get(haxes(2), 'TightInset') * [0 0 0 0; 0 0 0 0; 0 0 1 0; 0 0 0 0]);
The example indicates that the procedure works well for plot but not for plotyy. It seems that when I use plot, TightInset takes into account the text on the bottom and on the top (as it should), but it doesn't take them into account when I use plotyy. But I don't understand why this is the case and how to fix it. Any ideas?
Risposte (0)
Vedere anche
Categorie
Scopri di più su Two y-axis 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!