Thread Subject: Extracting Data from Plots

Subject: Extracting Data from Plots

From: First Last

Date: 21 Aug, 2007 19:02:40

Message: 1 of 3

I have a set of plots saved in MATLAB .fig format. Each one
has several subplots. I was wondering if there was a
functional form (i.e. non-GUI) of extracting data such as
the first data point in the graph. I noticed that in the
GUI, this information is available, so it's gotta be there
somewhere!

I am familiar with the following. For a given graph:

h = plot(1:10);
yData = get(h,'YData');

since YData becomes a property of h. For whatever reason, in
my subplots, YData is not a property. So when I have

h = subplot(3,3,1);
yData = get(h,'YData');

an error obviously occurs. I looked through the properties
of gca, and there didn't seem to be anything akin to YData
for subplots.

Any ideas on how to extract a data point's info from the
subplot? Oh, and I should mention that it could be a case of
multiple pieces of data per subplot. But being able to
extract any point should be possible, I would think.

Thanks in adv.

Subject: Extracting Data from Plots

From: First Last

Date: 21 Aug, 2007 19:55:51

Message: 2 of 3

Solution:

get(get(gca,'Children'),'YData');

Multi-line plots will have multiple arrays in which the data
is stored. Thanks to a colleague of mine for pointing this
out to me!

Subject: Extracting Data from Plots

From: Yair Altman

Date: 24 Aug, 2007 08:06:40

Message: 3 of 3

You might try looking at PlotData on the File Exchange, and
the m-code within it:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=15372

Yair Altman
http://ymasoftware.com


"First Last" <nospam@nospamplease.com> wrote in message
<fafcsg$3l1$1@fred.mathworks.com>...
> I have a set of plots saved in MATLAB .fig format. Each one
> has several subplots. I was wondering if there was a
> functional form (i.e. non-GUI) of extracting data such as
> the first data point in the graph. I noticed that in the
> GUI, this information is available, so it's gotta be there
> somewhere!
>
> I am familiar with the following. For a given graph:
>
> h = plot(1:10);
> yData = get(h,'YData');
>
> since YData becomes a property of h. For whatever reason, in
> my subplots, YData is not a property. So when I have
>
> h = subplot(3,3,1);
> yData = get(h,'YData');
>
> an error obviously occurs. I looked through the properties
> of gca, and there didn't seem to be anything akin to YData
> for subplots.
>
> Any ideas on how to extract a data point's info from the
> subplot? Oh, and I should mention that it could be a case of
> multiple pieces of data per subplot. But being able to
> extract any point should be possible, I would think.
>
> Thanks in adv.

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
plots First Last 21 Aug, 2007 15:05:05
rssFeed for this Thread

Contact us at files@mathworks.com