Re: Suppressing display of LogPlots
- To: mathgroup at smc.vnet.net
- Subject: [mg22604] Re: [mg22568] Suppressing display of LogPlots
- From: Hartmut Wolf <hwolf at debis.com>
- Date: Mon, 13 Mar 2000 11:03:21 -0500 (EST)
- Organization: debis Systemhaus
- References: <200003112252.RAA03265@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Dr Dan schrieb: > > There is a programming oversight (er, bug) in the Graphics` package > that interferes with the delayed evaluation of DisplayFunction > options. A common trick to suppress the display of graphics is to wrap > Plot in a Block function: > > In[1]:= > Block[{$DisplayFunction = Identity}, > g1 = Plot[Sin[x], {x, 0, 3*Pi}]; ]; > > In[2]:= > Show[g1] > > ---------plot deleted > Out[2]= > -Graphics- > > However, this trick does not work for many plot types defined in the > Graphics`Graphics` package: > > In[3]:= > << "Graphics`Graphics`" > > In[4]:= > Block[{$DisplayFunction = Identity}, > g2 = LogLinearPlot[Sin[x], {x, 0, 3*Pi}]; ]; > > In[5]:= > Show[g2] > > ------------- plot doesn't show! > Out[5]= > -Graphics- > > We can see why the plot does not display outside the Block by checking > the DisplayFunction options in the graphic: > > In[6]:= > Options[g2, DisplayFunction] > > Out[6]= > {DisplayFunction -> Identity, DisplayFunction :> Identity} > > I have tracked this bug to the utility functions ScaledPlot and > ScaledListPlot in Graphics.m. Since I am not brave enough to attempt > to fix the code, I created the following hack: > > DisplayFunctionHack[Graphics[args__, > (opts___)?OptionQ]] := Graphics[args, > {Flatten[{DisplayFunction :> $DisplayFunction, > DeleteCases[Flatten[{opts}], (Rule | RuleDelayed)[ > DisplayFunction, _]]}]}] > > The DeleteCases is not strictly necessary, but I like to clean up. We > can see the effect of the hack by checking the options of the graphic > again: > > In[8]:= > g3 = DisplayFunctionHack[g2]; > > In[9]:= > Options[g3, DisplayFunction] > > Out[9]= > {DisplayFunction :> $DisplayFunction} > > Now the graphics displays properly: > > In[10]:= > Show[g3] > > ----------------graphic deleted, but trust me, it was here. > Out[10]= > -Graphics- > > Sent via Deja.com http://www.deja.com/ > Before you buy. Dr. Dan, if I do In[7]:= Show[g2, DisplayFunction -> $DisplayFunction] -- Graphics deleted, was there -- Out[7]= Graphics[] I see the plot, so where's the bug? Block gives you the guarantee that the plot operations inside wouldn't show, nothing else! If $DisplayFunction -- the current "default display function" -- is explicitly referenced inside the Block as part of a definition, the referenced value will prevail, e.g. inside of g2. Of course you can reset this immediately: In[10]:= g2 = Block[{$DisplayFunction = Identity}, LogLinearPlot[Sin[x], {x, 0, 3*Pi}]] /. {(DisplayFunction -> Identity) -> (DisplayFunction -> $DisplayFunction)} Out[10]= Graphics[] In[11]:= Show[g2] -- Graphics deleted, was there -- Out[11]= Graphics[] Hartmut
- References:
- Suppressing display of LogPlots
- From: Dr Dan <drdanw@my-deja.com>
- Suppressing display of LogPlots