extracting data series from *.fig file

Hi there,
I have a figure file, but not the original data.
Is there a way to extract the data array from the 2D plot, opened from *.fig file?
Thanks in advance,
Petr.

1 件のコメント

shubham kumar gupta
shubham kumar gupta 2022 年 9 月 10 日
many a time it may happen you really get confused by varying answers non of them working
So follow this
S = load('MyFigure.fig', '-mat');
Now open S and go to children -> children -> Properties
Now search for CData, or XData, YData & ZData
you can export these variables

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

 採用された回答

Paulo Silva
Paulo Silva 2011 年 3 月 10 日

10 投票

open data.fig %open your fig file, data is the name I gave to my file
D=get(gca,'Children'); %get the handle of the line object
XData=get(D,'XData'); %get the x data
YData=get(D,'YData'); %get the y data
Data=[XData' YData']; %join the x and y data on one array nx2
%Data=[XData;YData]; %join the x and y data on one array 2xn

3 件のコメント

kaushal patel
kaushal patel 2016 年 3 月 22 日
how can i get the ordinates of curve shown in figure ,can anyone give me the solution of this problem.......
Amir
Amir 2016 年 7 月 18 日
Awesome! totally saved my time on retrieving the data. Works on 2016
Omar Velazquez
Omar Velazquez 2020 年 3 月 25 日
@Paulo Silva - You have saved my life. Many thanks

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

その他の回答 (3 件)

Petr
Petr 2011 年 3 月 10 日
編集済み: Walter Roberson 2015 年 9 月 19 日

2 投票

err.. tried it, it tells me
>> D=get(gca,'Children');
>> XData=get(D,'XData');
??? Error using ==> get
Invalid property found.
Object Name : hggroup
Property Name : 'XData'.
It's MATLAB 7.10.0 (R2010a)

4 件のコメント

Paulo Silva
Paulo Silva 2011 年 3 月 10 日
It looks like you got more things inside it than I was expecting, please do
D=get(gca,'Children'); get(D)
that will allow you to see what's there in the command line
Paulo Silva
Paulo Silva 2011 年 3 月 10 日
D=get(gca,'Children'); Child=get(D)
Now explore the Child struct and see what's inside, to get values from there is just similar to the code I gave you.
Joseph
Joseph 2015 年 9 月 19 日
編集済み: Walter Roberson 2015 年 9 月 19 日
This code generated an error:
openfig(figureFile);
D = get(gca,'Children');
Child = get(D);
??? Error using ==> get
Objects must all be instances of the same class.
Walter Roberson
Walter Roberson 2015 年 9 月 19 日
hfig = openfig(figureFile);
d = findall(hfig, '-property', 'xdata');
xydatas = arrayfun(@(h) get(h, {'xdata','ydata', 'type'}), d, 'Uniform', 0);
Now xydatas will be a cell array with one entry for each object in the plot that has an xdata property. Each of the cells will have three elements: the xdata information, the ydata information, and the name of the type of the object. Different kinds of objects might be included, depending on what was drawn in the plot.
The original question is not precise about what kind of 2D plot is present. For example, lines, surfaces, patches, and scatter plots are all 2D plots that have xdata properties.

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

Petr
Petr 2011 年 3 月 10 日

0 投票

Thanks, it works!
Probably, something was wrong with my file.

1 件のコメント

Walter Roberson
Walter Roberson 2011 年 3 月 10 日
Probably not, hggroup are not uncommon for some kinds of plots. In future you could use findobj() to locate the objects that have xdata.

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

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2011 年 3 月 10 日

コメント済み:

2023 年 7 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by