Re: making a Module or Column that will print lines interspersed with plots
- To: mathgroup at smc.vnet.net
- Subject: [mg129687] Re: making a Module or Column that will print lines interspersed with plots
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Mon, 4 Feb 2013 01:20:37 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20130203074603.82DEF68A3@smc.vnet.net> <20130204012416.D66936930@smc.vnet.net>
For the record, a semi-colon does _not_ in itself suppress output. Rather, a semi-colon separates the constituent expressions of a compound expression. When, however, there is a terminal semi-colon, the compound expression is treated as if there were a Null after that semi-colon. And Null returns no output. Hence the behavior is _as if_ the terminal semi-colon suppresses the output of the preceding expression. On Feb 3, 2013, at 8:24 PM, Murray Eisenberg <murray at math.umass.edu> wrote: > This sort of thing has been asked about and answered in this newsgroup many times since Mathematica 6 appeared. The magic cure is to wrap each graphic with Print: > > macro := Module[{j}, > Print["something"]; > Print[plota]; > Print["something else"]; > Print[plotb] > ] > > (Pretty-printing there just for structural clarity.) > > And since you define "macro" with SetDelayed ( := ), there's no need for the semicolon you have terminating the whole piece of code. > > Explanation: in Mathematica <= 5, the appearance of a graphic display was a side-effect; in Mathematica >= 6, the graphic display is the direct output as result. This implies that if you have some graphic object plotObject and use it in the form "plotObject;" with a trailing semi-colon, that just as with any other Mathematica expression, this suppresses the output. Hence when you are using a semi-colon to separate the component expressions of a compound expression -- as you are doing inside a Module -- then you must do something to counteract the effect of such a trailing semi-colon. And Print does that. > > On Feb 3, 2013, at 2:46 AM, Bruce Shore <bwshore at me.com> wrote: > >> I run Mathematica 7. I have some legacy notebooks, from Mathematica 5, in which there were Modules such as >> >> macro :=Module[{j}, >> Print["something"]; >> plota; >> Print["something else"]; >> plotb >> ]; >> >> where plota and plotb were plots. Now with Mathematica 7 the semicolons prevent the plots from showing up. Show[plota]; has the same problem. The semicolons, which are needed in a Module, prevent the plotting. I have tried using a Column or a Graphics column, >> >> macro:=Column[{ >> Print["something"], >> plota, >> Print["something else"], >> plotb >> }] >> >> and this does the printing and the plotting, but all the printing comes at the beginning and all the plots come after that. I really want the printing to come in between the plots, in the order that I show them. How can I do this? >> >> >> >> --------------------------- >> Bruce Shore >> bwshore at me.com >> (925) 455 0627 >> -------------------------- >> >> >> > > --- > Murray Eisenberg murray at math.umass.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone 413 549-1020 (H) > University of Massachusetts 413 545-2838 (W) > 710 North Pleasant Street fax 413 545-1801 > Amherst, MA 01003-9305 > > > > > --- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2838 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- References:
- making a Module or Column that will print lines interspersed with plots
- From: Bruce Shore <bwshore@me.com>
- Re: making a Module or Column that will print lines interspersed with plots
- From: Murray Eisenberg <murray@math.umass.edu>
- making a Module or Column that will print lines interspersed with plots