Thread Subject: extracting data from .fig in 2007a - did the proceedure change?

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: Chris

Date: 23 Oct, 2007 15:33:04

Message: 1 of 9

I'd like to extract the original data from several
scatterplot .fig files. However, using load('filename','-
mat') does not produce xdata and ydata files and the file
available here "getfigdata.m" also returns an error saying
it can't find "lh".

Does anyone know where the data is actually stored in
a .fig file under 2007a?

For instance, www.gaiteri.net/intrinsic_stress.fig
is one I just need to extract this very simple information
from. Thanks!

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: Chris

Date: 23 Oct, 2007 15:48:28

Message: 2 of 9

better link to file

www.gaiteri.net/stress_intrinsic.zip








"Chris " <cag44@removethispitt.edu> wrote in message
<ffl47g$q5v$1@fred.mathworks.com>...
> I'd like to extract the original data from several
> scatterplot .fig files. However, using load
('filename','-
> mat') does not produce xdata and ydata files and the
file
> available here "getfigdata.m" also returns an error
saying
> it can't find "lh".
>
> Does anyone know where the data is actually stored in
> a .fig file under 2007a?
>
> For instance, www.gaiteri.net/intrinsic_stress.fig
> is one I just need to extract this very simple
information
> from. Thanks!

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: PB

Date: 23 Oct, 2007 16:02:10

Message: 3 of 9

Den Tue, 23 Oct 2007 15:33:04 +0000 skrev Chris :

> I'd like to extract the original data from several
> scatterplot .fig files. However, using load('filename','-
> mat') does not produce xdata and ydata files and the file
> available here "getfigdata.m" also returns an error saying
> it can't find "lh".
>
> Does anyone know where the data is actually stored in
> a .fig file under 2007a?
>
> For instance, www.gaiteri.net/intrinsic_stress.fig
> is one I just need to extract this very simple information
> from. Thanks!

I get the following error trying to download your fig:

The page cannot be found...

Anyway, this might work:

%create figure

fplot(@humps,[0,1]);
saveas(gcf,'test','fig');
close(gcf); % close fig

% open the figure again
fighandle=openfig('test.fig');
ax=findall(fighandle,'Type','line');
x=get(ax,'Xdata')
y=get(ax,'YData')


HTH

PB

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: Peter Boettcher

Date: 23 Oct, 2007 16:03:22

Message: 4 of 9

"Chris " <cag44@removethispitt.edu> writes:

> I'd like to extract the original data from several
> scatterplot .fig files. However, using load('filename','-
> mat') does not produce xdata and ydata files and the file
> available here "getfigdata.m" also returns an error saying
> it can't find "lh".
>
> Does anyone know where the data is actually stored in
> a .fig file under 2007a?
>
> For instance, www.gaiteri.net/intrinsic_stress.fig
> is one I just need to extract this very simple information
> from. Thanks!

load the file, then start digging through the resulting structure:

>> a = load('filename', '-mat')

a =

    hgS_070000: [1x1 struct]

>> a.hgS_070000

ans =

          type: 'figure'
        handle: 9
    properties: [1x1 struct]
      children: [2x1 struct]
       special: []

>> a.hgS_070000.children(1)
and
>> a.hgS_070000.children(2)

etc, etc, etc.

Eventually you'll find what you're looking for.

-Peter

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: Dan Haeg

Date: 23 Oct, 2007 17:26:50

Message: 5 of 9

"Chris " <cag44@removethispitt.edu> wrote in message
<ffl47g$q5v$1@fred.mathworks.com>...
> I'd like to extract the original data from several
> scatterplot .fig files. However, using load('filename','-
> mat') does not produce xdata and ydata files and the file
> available here "getfigdata.m" also returns an error saying
> it can't find "lh".
>
> Does anyone know where the data is actually stored in
> a .fig file under 2007a?
>
> For instance, www.gaiteri.net/intrinsic_stress.fig
> is one I just need to extract this very simple information
> from. Thanks!

This works:

s=hgload('inlet.fig')
h = findobj(s,'Type','line')
y=get(h,'ydata');
x=get(h,'xdata');

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: Chris

Date: 23 Oct, 2007 22:35:08

Message: 6 of 9

Hi Dan - thanks for the information.

I tried your exact code on one of my figures and findobj
always returns empty.

"Dan Haeg" <haegd@msoe.edu> wrote in message
<fflasp$skn$1@fred.mathworks.com>...
> "Chris " <cag44@removethispitt.edu> wrote in message
> <ffl47g$q5v$1@fred.mathworks.com>...
> > I'd like to extract the original data from several
> > scatterplot .fig files. However, using load
('filename','-
> > mat') does not produce xdata and ydata files and the
file
> > available here "getfigdata.m" also returns an error
saying
> > it can't find "lh".
> >
> > Does anyone know where the data is actually stored in
> > a .fig file under 2007a?
> >
> > For instance, www.gaiteri.net/intrinsic_stress.fig
> > is one I just need to extract this very simple
information
> > from. Thanks!
>
> This works:
>
> s=hgload('inlet.fig')
> h = findobj(s,'Type','line')
> y=get(h,'ydata');
> x=get(h,'xdata');
>
>

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: Chris

Date: 23 Oct, 2007 22:40:23

Message: 7 of 9

Hi Dan - thanks for the information.

I tried your exact code on one of my figures and findobj
always returns empty.

"Dan Haeg" <haegd@msoe.edu> wrote in message
<fflasp$skn$1@fred.mathworks.com>...
> "Chris " <cag44@removethispitt.edu> wrote in message
> <ffl47g$q5v$1@fred.mathworks.com>...
> > I'd like to extract the original data from several
> > scatterplot .fig files. However, using load
('filename','-
> > mat') does not produce xdata and ydata files and the
file
> > available here "getfigdata.m" also returns an error
saying
> > it can't find "lh".
> >
> > Does anyone know where the data is actually stored in
> > a .fig file under 2007a?
> >
> > For instance, www.gaiteri.net/intrinsic_stress.fig
> > is one I just need to extract this very simple
information
> > from. Thanks!
>
> This works:
>
> s=hgload('inlet.fig')
> h = findobj(s,'Type','line')
> y=get(h,'ydata');
> x=get(h,'xdata');
>
>

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: Dan Haeg

Date: 26 Oct, 2007 01:04:30

Message: 8 of 9

"Chris " <cag44@removethispitt.edu> wrote in message
<fflt8n$cpe$1@fred.mathworks.com>...
> Hi Dan - thanks for the information.
>
> I tried your exact code on one of my figures and findobj
> always returns empty.
>
> "Dan Haeg" <haegd@msoe.edu> wrote in message
> <fflasp$skn$1@fred.mathworks.com>...
> > "Chris " <cag44@removethispitt.edu> wrote in message
> > <ffl47g$q5v$1@fred.mathworks.com>...
> > > I'd like to extract the original data from several
> > > scatterplot .fig files. However, using load
> ('filename','-
> > > mat') does not produce xdata and ydata files and the
> file
> > > available here "getfigdata.m" also returns an error
> saying
> > > it can't find "lh".
> > >
> > > Does anyone know where the data is actually stored in
> > > a .fig file under 2007a?
> > >
> > > For instance, www.gaiteri.net/intrinsic_stress.fig
> > > is one I just need to extract this very simple
> information
> > > from. Thanks!
> >
> > This works:
> >
> > s=hgload('inlet.fig')
> > h = findobj(s,'Type','line')
> > y=get(h,'ydata');
> > x=get(h,'xdata');
> >
> >
>

If it is not too late this works for your scatter plot:

s=hgload('stress_intrinsic.fig')
h = findobj(s,'Type','hggroup')
y=get(h,'ydata');
x=get(h,'xdata');

Subject: extracting data from .fig in 2007a - did the proceedure change?

From: pipa

Date: 26 Feb, 2010 17:23:04

Message: 9 of 9

Thanks!
It was really helpful!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
extract data fr... Chris 23 Oct, 2007 11:35:04
rssFeed for this Thread

Contact us at files@mathworks.com