Top x axis' labels outside of figure
21 views (last 30 days)
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
axes1 = axes('Parent',figure1,'YScale','log','XScale','log','Layer','top');
hold on %doesn't work
plot([10 10],[0 10],'--k','LineWidth',2) %doesn't work
axis([1 50 1 50])
set(ylab, 'Units', 'Normalized', 'Position', [-0.1, 0.5, 0]);
ax2 = axes('Position',axes1.Position,'YScale','log','XScale','log','XAxisLocation','top','YAxisLocation','right','Color','none','YTick',);
axis(ax2,[1*100 50*100 1*100 50*100])
% Top x axis' label appears outside of figure
Image Analyst on 27 Dec 2020
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.
Siddhant Desai on 19 May 2022
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.