フィルターのクリア

Saving a figure with a textbox

9 ビュー (過去 30 日間)
Yoav Romach
Yoav Romach 2014 年 3 月 17 日
コメント済み: Yoav Romach 2014 年 3 月 17 日
Hey,
I've been trying to save a figure as a png, and it's working, but when I've added a textbox, it appears to save it without the text, the code I have:
uicontrol('Style','text','Position',[30 390 20 20],'String','(a)','FontSize',12,'FontWeight','bold')
set(gcf,'PaperUnits','inches','PaperSize',[5.5 4],'PaperPosition',[0 0 5.5 4])
print('-dpng','-r100','2a')
The textbox is added in this manner because I want it to appear outside of the axes (labeling of figures), If anyone has a better idea I'll be happy to know :) (This is what I found searching the web).
The save is being done like this to control the size of the pictures.

採用された回答

Kevin Claytor
Kevin Claytor 2014 年 3 月 17 日
Why not use text? It can still appear outside the axes;
x = linspace(0,2*pi);
y = sin(x);
h = figure;
plot(x,y);
text(-1,1,'(q)');
title('Sine wave q');
set(gcf,'PaperUnits','inches','PaperSize',[5.5 4],'PaperPosition',[0 0 5.5 4]);
print(h,'-dpng','-r100','2q');
Also, you say " I want it to appear outside of the axes (labeling of figures)," How is this different from an axes title?
  1 件のコメント
Yoav Romach
Yoav Romach 2014 年 3 月 17 日
Thanks, for some reason I was under the impression that "text" did not appear outside the axes, but obviously i was wrong.
It is also different from titles, because I want it to appear top and left of the figure, It's for articles - (a) (b) (c) and such.
Thanks again!

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 3 月 17 日
  3 件のコメント
Image Analyst
Image Analyst 2014 年 3 月 17 日
That was helpful at least I thought it was. There is a reason why export_fig is the #1 most downloaded app. Not only of all time , but week after week . And there is a reason why people ask question like yours almost every day - because the MATLAB figure saving methods evidently don't work for a lot of people . People have a lot more success with export_fig than the built in routines. Not that you can't do it with the built in routines, but I, like thousands of others, don't bother when export_fig works so well. So anytime people say they have trouble saving I just refer them to the FAQ. Sorry it was unhelpful to you.
Yoav Romach
Yoav Romach 2014 年 3 月 17 日
Ok, I see.
I'll try export_fig then as well.
May I suggest that you'll be informative in the initial reply/answer, the "Maybe read the FAQ" sounds a bit aggressive, especially when I go there and it's a brief paragraph saying that export_fig is better tool (which in my case, I've heard about) and it's not specific about my question...
Writing something more like what you wrote write now would have been better :) Or maybe something short in the lines of "The internal matlab save figures mechanism is a bit weak, try using export_fig and see if that helps, see the FAQ:..."
Thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by