Re: Question about Display
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: Question about Display
- From: twj
- Date: Wed, 21 Apr 93 08:22:58 CDT
David Deutsch writes: > If you save a graphic using the function > >Display["filename",graphics] > >can you read this graphic back into your Mathematica session? > >In[6]:= p1 = Plot[Sin[x],{x,0,2Pi}] > >Out[6]= -Graphics- > >In[7]:= Display["plot1", p1] > >Out[7]= -Graphics- > >In[8]:= Clear[p1] > >In[9]:= p1 = <<plot1 > >Syntax::sntx: Syntax error in or before > "/Courier findfont 10 scalefont setfont". (line 5 of "plot1") > ^ In this example Mathematica is attempting to parse the contents of the PostScript file as input. The PostScript will not parse as valid input. It is possible to read it in as a string. This can be done with ReadList: ReadList[ "plot1", Record,RecordSeparators->{}] in the example above will read the entire file into a string. This may not be what is intended. What may be desired is to turn the PostScript back into a Mathematica graphics object. This is not intrinsically impossible for a limited set of PostScript operators but is it necessary? It is quite straightforward to keep the original Mathematica graphics object. In[46]:= p1 >> plotobject In[47]:= p2 = << plotobject Out[47]= -Graphics- will save it in the file plotobject and then read it back in again. Tom Wickham-Jones WRI