MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Send graphics to file AND/OR to notebook with one DisplayFunction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71507] Re: Send graphics to file AND/OR to notebook with one DisplayFunction
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 21 Nov 2006 07:05:04 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ejtd86$irv$1@smc.vnet.net>

zac wrote:
> Hi All,
> I've posted this problem on Wolfram's Student Support Forum, but no
> full answer was given to it.
> 
> I've got this problem with Display:
> 
> Plot[x, {x, 0, 5}, DisplayFunction -> (Display[{"stdout", "test.gif"},
> #1, "GIF"]&)];
> 
> where the given format "GIF" seems to collide with the standard output.
> The target is to both display the plot in the notebook, and to save it
> into a file. If I don't feed the 3rd argument ("GIF"), the plot does
> appear in the notebook, and a file is being generated, although it is
> an empty gif file.
> 
> In more detail: the problem is that I want to make both the
> notebook-display and the file saving be independently suppressable.
> Take for example the code below:
> 
> Plot[x, {x, 0, 5},DisplayFunction ->
> Which[
> askToFile && askToConsole, (Display[{"stdout", "test.gif"}, #1, "GIF"]
> &),
> askToFile && ! askToConsole, (Display["test.gif", #1, "GIF"] &),
> ! askToFile && askToConsole, (Display[$Display, #1] &),
> ! askToFile && ! askToConsole, Identity
> ];
> ];
> 
> where the variables askToFile and askToConsole are booleans.
> 
> As far as I know, Export cannot be suppressed "from the inside".
> Furthermore, I do not want to make two statements, one for displaying
> the graphic with Plot (or Show), and one for saving it with Export. It
> seems to me that defining a new $DisplayFunction would be the best
> solution.
> 
> Any help would be appreciated.
> 
> Istvan
> 
Have you tried wrapping your plot within the display function 
(Display[channel, graphics, format])?

In[1]:=
Display["c:\\test1.gif", Plot[Sin[x], {x, 0, 2*Pi}], "GIF"];

Display["c:\\test2.gif", Plot[Sin[x], {x, 0, 2*Pi},
     DisplayFunction -> Identity], "GIF"];

HTH,
Jean-Marc


  • Prev by Date: Re: Numerical Integration
  • Next by Date: Re: Send graphics to file AND/OR to notebook with one DisplayFunction
  • Previous by thread: Re: Send graphics to file AND/OR to notebook with one DisplayFunction
  • Next by thread: ComplexityFunction affects set of transformations tried by Simplify