MathGroup Archive 2012

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125404] Trouble Getting Graphic Primitives in a Module to Display with Show Command
  • From: Kenneth Bures <kenbures at gmail.com>
  • Date: Mon, 12 Mar 2012 04:08:53 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

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: Typing Formula Steps in a Grid
  • Previous by thread: Re: pole/zero plot for TransferFunctionModel in the control system package?
  • Next by thread: Re: Trouble Getting Graphic Primitives in a Module to Display with Show Command