Re: Re: Graphics and DisplayFunction

*To*: mathgroup at smc.vnet.net*Subject*: [mg98239] Re: [mg98203] Re: Graphics and DisplayFunction*From*: John Fultz <jfultz at wolfram.com>*Date*: Fri, 3 Apr 2009 04:37:27 -0500 (EST)*Reply-to*: jfultz at wolfram.com

You have it basically right in identifying it as legacy behavior. Since DisplayFunction is generally irrelevant in the modern graphical world, there's been no real cause to reinvent it. Preserving its behavior makes it simpler to make legacy code work when you're running in the legacy graphics mode (i.e. having evaluated <<Version5`Graphics` ). Sincerely, John Fultz jfultz at wolfram.com User Interface Group Wolfram Research, Inc. On Thu, 2 Apr 2009 04:48:31 -0500 (EST), replicatorzed at gmail.com wrote: > Thanks for the answer Szabolcs, > > Ok, so if I understand it correctly then by using explicit > DisplayFunctions, I display the *thing*, that is the side effect of > the actual function. Obviously only things that are enclosed in Show > can be thus displayed with DisplayFunctions, and - however it's just a > guess - the various plot functions all utilize an internal Show which > encloses their internal graphics. Thus - secondarily - DisplayFunction > can be used with plotting functions as well. But then I simply don't > understand why DisplayFunction is an option for Graphics? Neither > > Graphics[Circle[], DisplayFunction -> Identity] > > nor > > Graphics[Circle[], DisplayFunction -> Print]; > > work as I would expect. I understand, that > > ListPlot[{1, 2, 3}, DisplayFunction -> Identity] > > is displayed because of the sideeffect, that is NOT suppressed by a > semicolon, while > > ListPlot[{1, 2, 3}, DisplayFunction -> Print]; > > displays the plot because of DisplayFunction Prints the sideeffect, > that is otherwise suppressed by the semicolon. > > Still I don't understand why DisplayFunction does not work on Graphics > as would be - for me - logical. Is this side-effect thing a frozen > suboptimal situation of the pre6 era (which I'm quite familiar with, > however I've never realized this difference, probably because I've > managed to live without ever need to use Graphics directly), which WRI > does not want to change? > > Istvan > > > Szabolcs Horv=E1t wrote: > > As you said, both produce Graphics expressions. (More precisely, Graphics > *is* a Graphics expression.) But there's a difference: while Graphics[] > is just a way to *represent* graphics, plotting functions also have a > side effect of *displaying* the graphics expressions that they produce. > > In Mathematica <= 5.2 it worked like this: Graphics expressions were > formatted in the front end as --Graphics--, and they could be rendered > with Show[] (which called a function specified in DisplayFunction) > > In Mathematica >= 6, Graphics expressions are formatted as the actual p= > icture they represent (in StandardForm/TranditionalForm). Apart from > this, everything works the same as in 5.2. Of course since the graphics > are formatted nicely in the front end, there's no need for displaying > them in an explicit way, so $DisplayFunction === Identity by default. > > But suppose now that you can't/don't use the front end for some reason, > or use an alternative front end. Now it does make sense to use an > explicit command for showing the graphics. Try opening the command line > version, and type <<Terminal` or <<JavaGraphics`. > > The reason for the semicolon not being highlighted after Graphics[]; is > that in 5.2 no one typed Graphics[...] expecting to get a plot, but using > Plot[...]; was quite common (to suppress displaying the return value, -- > Graphics--)