Re: Plot in a Module
- To: mathgroup at smc.vnet.net
- Subject: [mg123933] Re: Plot in a Module
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Sat, 31 Dec 2011 02:00:41 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201112281016.FAA08942@smc.vnet.net>
- Reply-to: murray at math.umass.edu
I don't quite understand your question. There's nothing "illegal" or improper about omitting a semicolon after a Plot expression within a Module. For example, Module[{c}, c = 2; Print[Plot[c x, {x, 0, 1}]]] is perfectly legal. Perhaps your question is about a Module whose body has additional parts of the compound expression after the Plot part, e.g." Module[{c}, c = 2; Plot[c x, {x, 0, 1}]; c + 2] In this case, the red-highlighted semicolon that you'll see after the Plot expression is not an indicator of any syntactical error -- not "illegal" -- but a warning that you may not be getting what you expect, namely, that the Plot expression's output will be suppressed. (Just like if you simply typed a Plot expression alone, without any enclosing Module, and terminated it with a semicolon.) So what you want would be something like: Module[{c}, c = 2; Print[Plot[c x, {x, 0, 1}]]; 2 + 3] The Print wrapping the Plot forces the Plot output to be shown. Hope this helps. On 12/28/11 5:16 AM, Sam Takoy wrote: > Hi, > > How does one use the Plot command inside a Module? I find that if one > places a semi-colon after the command, then the output is suppressed. > But it also seems illegal to skip the semi-colon? So how does one do > it? > > Many thanks in advance, > > Sam > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- References:
- Plot in a Module
- From: Sam Takoy <sam.takoy@yahoo.com>
- Plot in a Module