saveas vs. "File->Save as"

Hi,
I am modifying the data tips to be visualized in the data cursor. Everything works fine, but when I save the figure .fig with saveas I lose all the changes I have done to the data tips.
Interestingly if I use instead the "File-> Save as" manually from the figure GUI, the changes to the figure are preserved. Am I missing something in the saveas command? The code is something like this:
figA=figure('name','Test');
h=plot(....);
addTagCursor(h,...);
hold on
h=plot(...);
addTagCursor(h,...);
saveas(figA, 'mypicture.fig');
Thanks for help!

1 件のコメント

Yogesh Babu
Yogesh Babu 2014 年 2 月 28 日
Hi, plot(Resultsforyyyy);figure(gcf); saveas(gcf,'Peile.fig') In the above line my pelie.fig is fixed one i want to use that with respect to the data i am plotting.Is that possible?

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

回答 (3 件)

Thomas
Thomas 2013 年 9 月 6 日

0 投票

try
saveas(gcf,'mypicture.fig')

3 件のコメント

Marco
Marco 2013 年 9 月 9 日
Unfortunately the command saveas(gcf,...) does not work either.
Jan
Jan 2013 年 9 月 9 日
If you post some code, which runs after a copy&paste, we could try to reproduce the problem. Hiding the interesting parts by "..." does not allow to test exactly what's going on.
Marco
Marco 2013 年 9 月 10 日
Hi, Thanks for help! I have tried many option, e.g. saveas(gcf,..), hgsave, etc. but with no luck so far. When I open the saved picture all the data tips I modified disappear.
Here is the code:
function test
a=[495156 495216 495276 495476 495516 495576 495676 495716 526396 542016]
b=[9790787 9798246 9805705 9836650 9843961 9855805 9878359 9883467 16173228 20990681]
c=[3 5; 6495542 7495542; 9848605 19848605; 432 657]
figB=figure('name','Test');
h=plot(a,ones(1,length(a)),'*r');
addTagCursor1(h, [cellstr(num2str(b'))... repmat(cellstr(num2str(-1)),length(cellstr(num2str(b'))),1)... repmat(cellstr(num2str(-1)),length(cellstr(num2str(b'))),1)]);
hold on
h=plot(c(2,:),ones(1,size(c,2)),'hk');
addTagCursor1(h, [cellstr(num2str(c(3,:)'))... cellstr(num2str(c(1,:)'))... cellstr(num2str(c(4,:)'))]);
hold on
saveas(figB,strcat(pwd,'\test.fig'));
end
function addTagCursor1(h,data)
set(h,'userdata',data)
dcmH = datacursormode(gcf);
set(dcmH, 'enable','on', 'UpdateFcn',@cursorUpdateFcn1, 'NewDataCursorOnClick',false);
end
function output_txt = cursorUpdateFcn1(obj,event_obj)
pos = get(event_obj,'Position');
labels = get(get(event_obj,'Target'),'UserData');
xvals = get(get(event_obj,'Target'),'XData');
yvals = get(get(event_obj,'Target'),'YData');
datapoint = find( (xvals==pos(1))&(yvals==pos(2)) );
output_txt = {['Time: ',num2str(pos(1))];... ['Y_axis: ',num2str(pos(2))];... ['Log Line: ',labels{datapoint,1}];... ['Value1: ',labels{datapoint,2}];... ['Value2: ',labels{datapoint,3}]};
end

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

Jan
Jan 2013 年 9 月 8 日

0 投票

You can use the debugger to check, what's going on inside saveas. Simply set a breakpoint inside this function, step through the code line by line and find out, which command influences the data tips.
Ilham Hardy
Ilham Hardy 2013 年 9 月 9 日

0 投票

For an alternative, try using hgsave() instead of saveas()

カテゴリ

ヘルプ センター および File ExchangePerformance and Memory についてさらに検索

質問済み:

2013 年 9 月 6 日

コメント済み:

2014 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by