Plotting on .fig file (in new window if possible)
38 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am trying to open a figure and plot additional data on it. The figure was given to me as a .fig file so I do not have the data to recreate it.
To open the file, I am using the following code:
fig = openfig('filename');
However that opens it in the script tab and not as a new figure window. How can I open it in a new figure window like all my other plots?
Once I have that opened (regardless of in new window or not), how do I plot on it?
I am trying
openfig('filename')
hold on
plot(x,y)
But that doesn't seem to be working.
Any help is greatly appreciated.
Thanks!
4 件のコメント
Stephan
2019 年 10 月 10 日
Upload the file means to attach the .fig file i guess- not a picture of it.
採用された回答
Walter Roberson
2019 年 10 月 9 日
Figures are container objects that cannot be directly drawn to. You can only plot() into axes. Axes are contained inside figures or inside uipanels (or a small number of other container types.)
In order to draw, you will need to either select an existing axes or else create a new axes inside the figure.
%get the figure
fig = openfig('filename');
%pull out the right axes
fig_axes = findobj(fig, 'type', 'axes');
selected_axes_idx = 2; %set as appropriate for your purpose
ax = fig_axes(selected_axes_idx);
%do the additional drawing
hold(ax, 'on');
x = linspace(-2*pi,2*pi);
y1 = cos(x);
plot(ax, x, y1, 'color', 'b');
hold(ax, 'off');
5 件のコメント
Walter Roberson
2019 年 10 月 10 日
I tested with the .fig you posted earlier, and it worked fine for me.
Which MATLAB release are you using?
その他の回答 (1 件)
Ankit
2019 年 10 月 9 日
Here is an example:
close all;
MySavedPlot = open('MySavedPlot.fig');
figure(MySavedPlot)
hold on
x = linspace(-2*pi,2*pi);
y1 = cos(x);
plot(x,y1,'color','b')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Specifying Target for Graphics Output についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!