MathGroup Archive 2012

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

Search the Archive

Re: Trouble Getting Graphic Primitives in a Module to Display with Show Command

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125428] Re: Trouble Getting Graphic Primitives in a Module to Display with Show Command
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Tue, 13 Mar 2012 03:08:16 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

remove the semicolon after the

sketchEarthOrbit[];

Nancy wrote her book of an earlier version of Mathematica where
graphics were a byproduct of evaluation rathe than the result of
evaluation.

--David

On Mar 12, 5:11 am, Kenneth Bures <kenbu... at gmail.com> wrote:
> I have been trying to display graphics primitives (lines, circles)
> from inside a module, but I can't get it to work. If you have Nancy
> Blachman's book, MATHEMATICA: A Practical Approach, 2nd Edition, she
> gives an example on page 399 of a 4-line module that generates 3
> graphics objects and then has a Show command (inside the module) to
> display them. I've listed the code below. The book illustrates that
> when you call this module from the main program with the instruction
> sketchEarthOrbit[] it displays the 3 graphics objects. When I copy
> this program exactly, it does not work. I get no output. If I cut &
> paste the exact four lines of code to outside of the module, they do
> display the desired result, so there seems to be is something wrong
> with her basic approach.
>
> Why doesn't this example work? Actually, what I would really like to
> do is pass the graphics objects out of the module, and display them
> from the main program, rather than having the Show inside the module.
> But I decided that I should understand what is wrong with Blachman's
> approach before I spend too much time on the other. Any help would be
> appreciated, either with explaining Blachman's approach and/or how to
> transfer graphics objects out of a module.
>
> Here is Blachman's code (I put the Clear command there):
>
> Clear[sketchEarthOrbit];
> sketchEarthOrbit[] :==
>   Module[{earth, sun, orbit},
>    earth ==
>     Graphics[{ Disk[{-.7, .35}, 0.05], Text["Earth", {-.7, .45}] }];
>    sun == Graphics[{ Disk[{.3, 0}, 0.1], Text["Sun", {.3, .17}] }];
>    orbit == Graphics[{ Circle[{0, 0}, {1., .5}] }];
>    Show[orbit, sun, earth, AspectRatio -> Automatic]
>    ];
> sketchEarthOrbit[];



  • Prev by Date: Re: Dynamically create Select criteria
  • Next by Date: Re: How to use Save/Get for interpolation of unstructured
  • Previous by thread: Re: Trouble Getting Graphic Primitives in a Module to Display with Show Command
  • Next by thread: Button Behavior OnClick