Why are the text labels cut off when I rotate and resize a surface plot in MATLAB 7.7 (R2008b)?

34 views (last 30 days)
I am creating a surface plot and labeling both the X and Y axes.
I have set the 'ActivePositionProperty' to 'OuterPosition' so that the text labels are preserved when the figure is resized.
However, when I change the orientation of the axes using VIEW and resize the figure the axis labels are cut off.
I need to embed this figure into my publication and therefore I want a particular figure and font size. I cannot resize the figure to be a little bigger or decrease the font size.
Please refer to the following code:
figure
hf = gcf;
set(hf,'Units','inches');
pos = get(hf,'Position');
pos(3) = 3.25; % width
pos(4) = 0.75 * pos(3); % height
set(hf,'Position',pos);
surf(peaks);
xlabel('X Axis');
ylabel('Y Axis');
set(gca,'ActivePositionProperty','OuterPosition');
%Resizing to smaller size to see whether labels are dropped
view(-80,65);
set(gcf,'Position',[pos(1) pos(2) pos(3)-1 pos(4)-1]);

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The ability to automatically preserve the text labels while rotating and resizing a figure is not available in MATLAB.
To work around this issue, you can adjust the position of the axes using the 'Position' property so the text labels fit inside the figure.
p = get(gca,'Position');
set(gca,'Position',[p(1) p(2)+0.1 p(3)-0.1 p(4)-0.2]);
You can also put the above code in the ResizeFcn to automate the process. You would still have to experiment with different axes positions to make sure that the text labels fit inside the figure.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!