MathGroup Archive 2001

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

Search the Archive

Re: LogPlot/Plot-Identity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27161] Re: LogPlot/Plot-Identity
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Thu, 8 Feb 2001 04:40:47 -0500 (EST)
  • References: <95b5ud$4lu@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Bernd, Hartmut

> Show[Block[{$DisplayFunction = Identity}, Plot[Exp[3 t], {t, 0, 5}]]]
> This just shows the graphic. However, in
>
> Show[Block[{$DisplayFunction = Identity}, LogPlot[Exp[3 t], {t, 0, 5}]]]


This is corrected in version 4.1


The problem was rather deep seated.
Below ************** is my posting in response to an earlier query about the
problem.
Of course, you need not bother with the corrections now, and in any case
the perceptive solution just posted by Hartmut Wolf,

Block[{$DisplayFunction}, Identity@@(graphics or plot expression)]

works in all cases when we want to temporarilly suppress display. I shall be
using it from now on.

Allan
************************************************************************
Dr Dan,
The likely cause is very interesting for any options that are set with
RuleDelayed(  :>  ).

Please make a copy of the file Graphics.m in the same folder as the original
and call it myGraphics.m.

Looking at this we see

In the usage notes,  DisplayFunction is set with RuleDelayed :
    DisplayFunction :> <value>
not Rule:
    DisplayFunction -> <value>

However we get

<< Graphics`Graphics`

Block[{$DisplayFunction = Identity}, LogLinearPlot[Sin[x], {x, 0, 3*Pi}]];

Options[%, DisplayFunction]

{DisplayFunction -> Identity, DisplayFunction :> Identity}

Now,  using Find to find DisplayFunction -> we find several inocuous cases
but eventually reach a case inside

(1)
Show[g, DisplayFunction -> disp,
                        PlotRange -> r,
                        AxesOrigin -> ao
                ]

We find that dis was defined earlier by

(2)
{scale, disp, ao} =
    {ScaleFunction, DisplayFunction, AxesOrigin}/.
   Flatten[{opts}]/.Options[ScaledPlot];

Although this is a common way of extracting the values for options it is
cause of the problem,  because it allows $DisplayFunction in DisplayFunction
:> $DisplayFunction to be evaluated inside Block[ ..] using the temporary
setting $DisplayFunction = Identity.

One way out is to replace (2)  with

{scale,  ao} =
    {ScaleFunction, AxesOrigin}/.
   Flatten[{opts}]/.Options[ScaledPlot];

dis = Cases[Flatten[{opts,Options[ScaledPlot]}],
    _[DisplayFunction,_]][[1]];

This gives dis = DisplayFunction:>$DisplayFunction with $DisplayFunction
unevaluated, because RuleDelayed has the attribute HoldRest.

and replace (1) with

Show[g,      disp,
                  PlotRange -> r,
                   AxesOrigin -> ao
                ].

There are two subsequent examples of this kind of problem in the code that
can be handled in the same way.

After dealing with these we get.

<< Graphics`myGraphics`

Block[{$DisplayFunction = Identity}, LogLinearPlot[Sin[x], {x, 0, 3*Pi}]];

Options[%, DisplayFunction]

{DisplayFunction :> $DisplayFunction, DisplayFunction :> Identity}

Show[%%]; (*displays the picture*)

You might like to tidy up so that  DisplayFunction :> Identity is not left
in.


Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565





--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Bernd Brandt" <bernd at bio.vu.nl> wrote in message
news:95b5ud$4lu at smc.vnet.net...
> Dear group,
>
> I am trying to plot several plots in one. This poses no diffuculties.
> But LogPlot seems to behave differently with regard to $DisplayFunction.
>
> I have a simple example:
>
> Show[Block[{$DisplayFunction = Identity}, Plot[Exp[3 t], {t, 0, 5}]]]
> This just shows the graphic. However, in
>
> Show[Block[{$DisplayFunction = Identity}, LogPlot[Exp[3 t], {t, 0, 5}]]]
>
> The $DisplayFunction remains Identity even with Show, thus no plot is
> produced in case of LogPlot.  Can someone explain this difference
> between Plot and LogPlot?
>
> Regards,
> Bernd
>
>






  • Prev by Date: Re: Functional programming
  • Next by Date: Re: Functional programming
  • Previous by thread: Re: LogPlot/Plot-Identity
  • Next by thread: Re: solving for 2 variables (beginner)