Reputation: 882
I am creating a GUI in MATLAB using GUIDE. I have several axes, and in one of them I want to draw a boxplot. My problem is that after drawing the boxplot, the size of the axes changes, and it overlaps with some of my other figures.
To replicate this problem, create a .fig
file using GUIDE
containing two axes: axes1
and axes2
, as shown in the figure: .
Then, in the OpeningFcn
, add the following lines:
Z = normrnd(1,3,[100,1]);
plot(handles.axes1, Z);
boxplot(handles.axes2,Z)
Then lauch the GUI. I see the following:
As you can see, the two axes overlap. I've tried changing the properties of the box plot, but with no luck.
I use MATLAB 7.10 (R2010a) and Kubuntu 12.10.
Upvotes: 4
Views: 1254
Reputation: 5348
It appears that boxplot
makes the axes grow wider, not sure why. In any case, saving the axes position right before plotting and resetting it right after seems to work for me:
Z = normrnd(1,3,[100,1]);
plot(handles.axes1, Z);
pos = get(handles.axes2, 'position');
boxplot(handles.axes2,Z);
set(handles.axes2, 'position', pos);
Cheers, Giuseppe
Upvotes: 7