- Get your boxplot to look the way you want it
- run the above loop do disable the listeners
- use the print command to output your plot
The position of x-label is reset to the original position when printing a 'boxplot' figure
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I want to adjust the position of x-label in a 'boxplot' figure and to save the figure in a 'png' format.
Although I adjusted the position of the x-label as bellow, the position was reset to the original position when printing the figure:
figure;
boxplot(randn(100, 3))
xlabel('Trial number')
h = get(gca, 'xlabel');
oldpos = get(h, 'Position')
set(h, 'Position', oldpos - [0, 20, 0])
print('-dpng', 'boxplot.png')
get(h, 'Position') % The position is reset !
Does anyone know how to fix this problem?
I'm using Matlab R2012b.
Thanks.
0 个评论
回答(1 个)
Andrew Davis
2013-9-9
I had this same problem -- very frustrating! Especially since this workaround indicates that the problem has existed for at least 3 years without a fix. The workaround didn't quite work as written for me, I used:
ax = findobj(gcf,'type','axes')
for j=1:length(ax),
boxparent = getappdata(ax(j),'boxplothandle');
listeners = getappdata(boxparent,'boxlisteners');
for i = 1:length(listeners),
listeners{i}.Enabled = 'off';
end
end
So, the procedure is:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!