|
From: Thomas S. <t.s...@fz...> - 2012-07-14 20:47:50
|
Andrew DeYoung <adeyoung <at> andrew.cmu.edu> writes: > > Hi, > > Suppose that I have a PostScript file containing a plot which was generated > using gnuplot. However, I do not have the source data, nor do I have the > gnuplot commands that were used to generate the plot. > > Do you know of any way to somehow extract data from a graphic representation > (i.e., a PostScript file)? Such code would have to literally "read off of > the graph" (in particular, I have a smoothed line/scatter XY plot) from the > pixel representation, and I know that the results would be approximate at > best (but this would still be very highly desirable). > > Do you have any experience with this? Thank you for your time! > > Andrew DeYoung > Carnegie Mellon University > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > gnuplot-info mailing list > gnuplot-info <at> lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > because postscript is a programming language, the postscript file contains all commands to generate the plot. you need to determine the box surrounding the plot (normally the axes) in postscript units (near the end of the postscript file), and then with the knowledge of the original axis ranges (which you see when printing/viewing the postscript file) you may transform the plotted points or lines back into the original coordinate system. with some basic knowledge of the postscript language it's relatively easy to extract the data. you may make a copy of the postscript file, open it with a normal text editor, and try to identify the components. sometimes it helps to change the color by inserting a line like 1.0 0.0 0.0 setrgbcolor into the file and see which lines turn to red when viewing the file with ghostscript. an example: somewhere in the prologe section some commands are redefined (to save filespace): ... /M {moveto} bind def /L {lineto} bind def /R {rmoveto} bind def /V {rlineto} bind def /N {newpath moveto} bind def /Z {closepath} bind def /C {setrgbcolor} bind def /f {rlineto fill} bind def /g {setgray} bind def ... later in the file these commands are used (the following is near the end of the file): ... % End plot #1 stroke LTb 546 4871 N 546 280 L 6401 0 V 0 4591 V -6401 0 V Z stroke 1.000 UP 1.000 UL LTb stroke grestore end showpage ... the above draws the box around the plot moveto 546 4871 lineto 546 280 relativelineto 6401 0 relativelineto 0 4591 relativelineto -6401 0 that means the xaxis ranges from 546 to 6947 and the yaxis from 280 to 4871. i plotted a sin function using default ranges (i.e. xrange [-10:10], yrange [-1:1]), so for the xaxis 546 corresponds to -10. 6947 corresponds to 10. and for the yaxis 280 corresponds to -1. 4871 corresponds to 1. the datapoints or function line segments are plotted the same way like the above box: ... 546 3824 M 65 -412 V 64 -445 V 65 -462 V 65 -459 V 64 -438 V ... which is (in original coordinates): moveto -10.,0.5438 rlineto 0.0203, -0.1795 rlineto 0.0200, -0.1939 a.s.o. |