RE: AW: LogPlot/Plot-Identity

*To*: mathgroup at smc.vnet.net*Subject*: [mg27128] RE: [mg27115] AW: [mg27041] LogPlot/Plot-Identity*From*: "David Park" <djmp at earthlink.net>*Date*: Sun, 4 Feb 2001 21:27:11 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

Dear Hartmut and Bernd, I have to put in a little plug for my DrawingPaper package here. The thing about a routine like LogPlot is that it not only produces the primitives for the graph, but also all the options for the tick marks which we are most interested in. So we want to combine the graphics primitives for a number of plots with the overall options from one plot that generates the tick marks and values. DrawingPaper has the following routines that allow this. DrawingPaper automatically loads Graphics`Colors`. Needs["Graphics`DrawingPaper`"] Needs["Graphics`Graphics`"] ?DrawGraphics "DrawGraphics[plot[args]] will extract the primitive graphics, without \ display, from any plot that produces Graphics output or can be converted to \ Graphics output. It will handle plot routines produced by packages which were \ not anticipated by the author of DrawingPaper." ?DrawWithOptions "DrawWithOptions[plot_[args_] will extract the primitive graphics for the \ plot, and the option rules used by the plot. It can be used when you wish to \ pick up the overall plot options of some plot to use in the Show statement. \ The usage would be:\n{primitives,options} = DrawWithOptions[plot[args]]" So, the following routine combines three different log plots in one graphics - and you don't even have to think about DisplayFunction. Additional overall options can be added before the extracted options from LogPlot. Module[ {firstprims, opts}, {firstprims, opts} = DrawWithOptions[LogPlot[Exp[3 t], {t, 0, 5}, Frame -> True]]; Show[Graphics[ {firstprims, Blue, DrawGraphics[LogPlot[Exp[2 t], {t, 0, 5}]], Red, DrawGraphics[LogPlot[Exp[2 t] + 100, {t, 0, 5}]]}], FrameLabel -> {t, "functions"}, PlotLabel -> "Combining Log Plots", opts]]; DrawingPaper can be obtained from my web site below. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > -----Original Message----- > From: Wolf, Hartmut [mailto:Hartmut.Wolf at t-systems.de] To: mathgroup at smc.vnet.net > Sent: Sunday, February 04, 2001 2:59 AM > To: mathgroup at smc.vnet.net > Subject: [mg27128] [mg27115] AW: [mg27041] LogPlot/Plot-Identity > > > > > -----Ursprüngliche Nachricht----- > Von: bernd at bio.vu.nl [mailto:bernd at bio.vu.nl] > Gesendet: Donnerstag, 1. Februar 2001 09:00 > An: mathgroup at smc.vnet.net > Betreff: [mg27041] LogPlot/Plot-Identity > > > 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 > > > Dear Bernd, > > although this is folklore recommended procedure, it has to be > regarded with > suspicion. You have to look at what you get: > > g1 = Block[{$DisplayFunction = Identity}, Plot[Exp[3 t], {t, 0, 5}]] > > Options[g1, DisplayFunction] > {DisplayFunction :> $DisplayFunction} > > So here in the result all is fine, when you execute > > Show[g1] > > you'll use the value of $Display function in the execution environment of > Show. > But for > > g2 = Block[{$DisplayFunction = Identity}, LogPlot[Exp[3 t], {t, 0, 5}]] > > Options[g2, DisplayFunction] > {DisplayFunction -> Identity, DisplayFunction :> Identity} > > You see that the temporary value of $DisplayFunction of Block has been > smuggled into the graphics object. I cannot tell this a bug of > LogPlot (and > similar routines, and if you write your own plotting routines you'll find > out it's not easy to prevent all references to the unevaluated > $DislayFunction). This here (is a more correct alternative, I think): > > g2a = Block[{$DisplayFunction}, Identity @@ LogPlot[Exp[3 t], {t, 0, 5}]] > > This construct keeps all references to $DisplayFunction as > unevaluated, and > applying Identity to the final result prevents the display. > > Options[g2a, DisplayFunction] > {DisplayFunction -> (Display[$Display, #1] &), DisplayFunction :> > Identity} > > Show[g2a] > > It's interesting to compare that with straight plotting: > > g2x = LogPlot[Exp[3 t], {t, 0, 5}] > > Options[g2x, DisplayFunction] > {DisplayFunction -> (Display[$Display, #1] &), DisplayFunction :> > Identity} > > So we had got the same, the right say, graphics object! (witout displaying > it) > > -- Hartmut Wolf > > >