Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

very SIMPLE question about a FIGURE

Status
Not open for further replies.

antiseptic

Bioengineer
Jan 15, 2003
11
hi all
okay, i have a simple plot saved in a .fig file
i JUST need to RETRIEVE the data of the Y axis
i m SURE it can be done, but i cant figure it out
i have even SEEN the data when editing the plot but i cant save it to workspace
help?
 
Replies continue below

Recommended for you


were are the original data? I mean, you ploted that from one Variable from workspace, right?. that variable exist?

 
well, maybe the workspace was deleted, unsaved or so on, so the only proof for data is the figure..

sorry: real interesting, but I can't help you..

good luck!
 
hi
yes, the original data was deleted, now i just have the .fig file left

i m really buggered, cuz i CAN see the data, i just need to "edit" the plot, then click on Y axis, and the data is THERE!! (check it out), but theres no option to "save it to workspace", as can be done with the "basic fitting" (mean, std, variance...)

if i have no other choice, i can RETYPE the data by hand (i insist, its there), though is just CANT believe there is no other way to retrieve it!!

i tried to edit the .fig file but its a load of cr*p :-(

anyone help?

P.D. if anyone sorts this out, this ought to go to the HALL OF FAME, truely...
 
ok, me again
its 3 am, and im listening to limp bizkit to keep my mind sharp

i think i got a "partial" solution, nuff for me today, ill try to find something better tomorrow

ok, so i just have the fig

>> open crappy.fig
>> gcf % returns the handle of the current figure
>> saveas(gcf, 'crappy', mmat) % that should create a crappy.fig and a crappy.m, ignore any warning msg

>> edit crappy.m
% scroll down and u will find something like 'YData',[2 11 7 14]);' (this is just a stupid example, i used durer magic matrix

well, at least now i only have to "cut & paste" if the number is low

if its a big number (hundreds ++) it will also create a file called crappy.mat, its a cell array
just type

>> load crappy

and it will get to ur workspace as a "mat" variable
mat{i} is the ith-dimension

well, im going to get some deserved sleep...
 
Its possible to extract the data from a figure. In Matlab R12 onwards (atleast) a figure is actually an active object. The figure oject can contain a number of "children". Also objects (line, legend, text, buttons, etc.). Each one of these children have their own properties and their own children. The data you plotted is contained within a "line" object. To access this you must do something like this.

Open myfig.gif
myfigId=gcf;
myfigChildren=get(myfigID, 'Children');
%returns all the children in an array

%now you must identify which one of these children is the line you are interested in. To do this type

get(myfigChildren(1));
get(myfigChilfren(2));

%... etc untill you see some data in the Xdata Ydata properties. Then..

%lets say that the line you want is object 2 in the figure
%so now

myline=get(myfigChildren(2));
myxdata=get(myline,'Xdata');
myydata=get(myline,'Ydata');

%and voila, Hope this helps

JR.



 
thanx a lot
i had been looking through the set and get functions, but hadnt quite grasped how to use em

 
i had the same problem with extracting data from a .fig file, and came across a solution at:


excerpt from the above URL:
----start excerpt-----
openfig('MyTestFig.fig');
HandlesOfLines=findobj(gcf,'type','line');
% This reopens the figure and finds the Line object inside it

XData = get(HandlesOfLines,'Xdata')
YData = get(HandlesOfLines,'Ydata')
% This retrieves the X and Y data, which are:

XData =
1 2 3 4 5 6 7 8 9 10
YData =
10 9 8 7 6 5 4 3 2 1

As you can see, these are the inputs we passed to the PLOT command.

You may have some issues with finding the right line from which to retrieve the X and Y data if you have multiple lines in the figure ... but hopefully they have some other distinguishing characteristic that you can use with the
FINDOBJ command.

--
Steve Lord
slord@mathworks.com
----end excerpt-----
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor