upper axis title doesn't fit in the output of my plot
7 ビュー (過去 30 日間)
古いコメントを表示
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?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/345654/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/345654/image.jpeg)
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}]']);
0 件のコメント
採用された回答
Adam Danz
2020 年 8 月 13 日
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!