MathGroup Archive 2000

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

Search the Archive

Suppressing display of LogPlots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22568] Suppressing display of LogPlots
  • From: Dr Dan <drdanw at my-deja.com>
  • Date: Sat, 11 Mar 2000 17:52:41 -0500 (EST)
  • Organization: Deja.com - Before you buy.
  • Sender: owner-wri-mathgroup at wolfram.com

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.


  • Prev by Date: Re: iterations, recursions and derivatives
  • Next by Date: Re: iterations, recursions and derivatives
  • Previous by thread: Re: Question
  • Next by thread: Re: Suppressing display of LogPlots