Top x axis' labels outside of figure
25 ビュー (過去 30 日間)
古いコメントを表示
The label of the top x axis appears outside of the figure, how can this be fixed?
Also, for some reason I don't understand, "hold on + plot()" doesn't work in this case, I would like to be able to plot a vertical line but this doesn't appear on the figure either
figure1=figure(4)
axes1 = axes('Parent',figure1,'YScale','log','XScale','log','Layer','top');
grid(axes1,'on');
hold(axes1,'on');
[C,h]=contourf(peaks,[10],'LineColor','none');
clabel(C,h);
hold on %doesn't work
plot([10 10],[0 10],'--k','LineWidth',2) %doesn't work
axis tight;
axis([1 50 1 50])
xlabel('\lambda_x','Fontsize',20);
ylab=ylabel('y^+','Fontsize',20);
grid off
set(ylab, 'Units', 'Normalized', 'Position', [-0.1, 0.5, 0]);
set(gca,'linewidth',1.5,'FontSize',16)
colormap(flipud(gray(256)));
colorbar;
ax2 = axes('Position',axes1.Position,'YScale','log','XScale','log','XAxisLocation','top','YAxisLocation','right','Color','none','YTick',[]);
xla2=xlabel(ax2,'\lambda_x^+','Fontsize',20);
axis(ax2,[1*100 50*100 1*100 50*100])
set(ax2,'linewidth',1.5,'FontSize',16)
% Top x axis' label appears outside of figure
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/471437/image.jpeg)
2 件のコメント
Mischa Kim
2020 年 12 月 27 日
Carlos, how do you want the figure to look like? Is this for an app or a standalone figure?
回答 (2 件)
Image Analyst
2020 年 12 月 27 日
I've seen that before too, like when my title font size is too big. You can reduce the axes size to get it to fit by setting the 'InnerPosition', 'OuterPosition', or 'Position' property.
ax = gca
ax.units = 'normalized';
ax.Position = [0.1, 0.1, 0.7, 0.7]; % Adjust as needed to get the size and location correct.
8 件のコメント
Image Analyst
2020 年 12 月 28 日
I don't really know. I'm not going to experiment around with it anymore. Can you call tech support? They're open now.
Siddhant Desai
2022 年 5 月 19 日
I have faced a similar issue where the colorbar labels end up outside the plot area. I don't know how to automate the resizing so that everything fits and end up having to do it manually which is very cumbersome.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!