upper axis title doesn't fit in the output of my plot

14 visualizzazioni (ultimi 30 giorni)
hello everyone
i m plotting a graph on one Y axis and 2 X axis
each X axis has a title
the title shows on the bottom axis however it doesnt show on the upper axis (it seems to be truncated by the size of the paper.
(the only way to show it is to change completely the proportion of my plot (instead of 18x12 cm it should be 18x16 or so..)
any hint on how to fit the upper axis title while keeping the same horizontal proportion?
code below:
set(gcf,'units','centimeters','outerposition',[2 2 18 12]);
set(gcf,'units','centimeters','paperposition',[0 0 18 12]);
set(gca,'yscale','log');
set(gca,'xscale','linear');
ax1 = gca; % current axes
ylabel(['mass fraction','%']);
xlim([0.0,1.4]);
ylim([0.0001,1]);
yticklabels([ 0.01 0.1 1 10 100]);
xlabel(['enclosed mass','[M', solar,']']);
legend( 'Location', 'Southwest' );
legend boxoff;
set(gca,'box','off')
set(legend,'FontSize',8);
set(gca,'linew',1.2)
solar = char(9737);
Ang=char(197);
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
xlim([0.0,1.4]);
xticks([0.185 0.316 0.6 0.837 1.085 1.24 1.36 ]);
xticklabels([3800 5000 7500 10000 12500 15000 17500 ]);
set(gca,'yscale','log');
ylim([0.0001,1]);
yticklabels([ ]);
set(gca,'linew',1.2)
xlabel(['velocity','[km s^{-1}]']);

Risposta accettata

Adam Danz
Adam Danz il 13 Ago 2020
Reduce the height of the first axis
% This reduced the height to 80%
% Play around with the value to get what you want
ax1.Position(4) = ax1.Position(4)*.80;
Then link the ax1 and ax2 axes.
linkaxes([ax1,ax2])
  6 Commenti
Adam Danz
Adam Danz il 13 Ago 2020
Good! Then no need to link the axes or its properties :)
charles aouad
charles aouad il 13 Ago 2020
Adam, Thank you soo much !
your help was substantial and really appreciated.
kind regards

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by