Get data from Contour plots

5 views (last 30 days)
Lavkesh Lachhvani
Lavkesh Lachhvani on 8 Jun 2011
Hi all,
I have been using matlab since quite long. I want to get data from the stored contour plot file. I can get it's handle using hggroup, but I don't know how to extract data from this ?
Can anybody help ?
thanx in advance..

Answers (4)

Walter Roberson
Walter Roberson on 9 Jun 2011
The Children of the hggroup are a set of patches, one patch per contour level.
The patches are basically X/Y/Z lists of coordinates, with the Z originally set to be constant at the contour level. The transitions between the various regions of contouring are, if I recall correctly, done by sticking NaN in to the list of points where the breaks are.
After the utility routine constructs all of these patches, the contour() routine deliberately goes through and sets the Z coordinates for all of the patches to 0, destroying the original Z. Fortunately, the utility routine that constructed the layered patches also stored the patch level (Z coordinate) in the UserData field associated with the patch, so it is possible to determine which patch is which by looking at its UserData field.
The contour regions are sometimes quite irregular, especially if two regions with the same level touch each other: in such a case it is not certain that those two regions will be done through X1 NAN X2 NAN or if it will just build X1 X2 NAN.

Lavkesh Lachhvani
Lavkesh Lachhvani on 9 Jun 2011
Thanks Walter for your explanation, I got the way to extract data, here it is...
plot1 = openfig('*.fig');
h1 = findall(plot1,'Type','hggroup');
X1 = get(h1(2),'XData');
Y1 = get(h1(2),'YData');
Z1 = get(h1(2),'ZData');

Roman Voronov
Roman Voronov on 12 Feb 2013
This works for contour3, for contour the Z is empty

mohammad pourtousi
mohammad pourtousi on 7 May 2013
Hello I have some single data based on x,y,z .I want to contour them. Actually x,y are show rectangular geometry and z shows pressure in this geometry.
How Can i contour them? Thanks

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!