MathGroup Archive 2008

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

Search the Archive

Re: Why don't my plots appear? My 5.2 code no longer works

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89342] Re: [mg89326] Why don't my plots appear? My 5.2 code no longer works
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sat, 7 Jun 2008 02:50:40 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200806061044.GAA24071@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

You'll probably get zillions of responses to your question.

The treatment of Plot and related functions has changed with version 6: 
the graphic created is no longer a side-effect of evaluating the 
function, but rather the actual, direct RESULT of the function.  (In 
Mathematica 5 and before, the display was a side-effect whereas the 
direct result was a -Graphics- object.)

A consequence is that following a Plot with a semi-colon now has EXACTLY 
the same effect of following any other command with a semi-colon: it 
suppresses the result.  More precisely, it produces a Null result, which 
by default is not shown in any way.

In general, a semi-colon is used to separate the parts of a compound 
expression, for example:

   a = 2; Plot[Sin[a x], {x, 0, Pi}]; "Hello, world!"  (* NO! *)

has result the string 'Hello, world!.  And indeed in Mathematica 6 you 
the semi-colon after the Plot expression appears in red to warn you.  To 
make the plot appear, use Print:

   a = 2; Print[Plot[Sin[a x], {x, 0, Pi}]]; "Hello, world!"  (* Yes *)

Note this has nothing to do, per se, with Modules -- just compound 
expressions in general.


Charlie Brummitt wrote:
> Hello,
> I am running into difficulties with Plot. Some code of mine that worked in
> 5.2 no longer works correctly in 6.0.2.0. Specifically, no plots appear
> whenever Plot (or Plot3D or DensityPlot or ListPlot) is called within a
> function that I have defined.
> 
> Here is a closely related question: What does the red semicolon ";" mean at
> the end of "Plot[ ... ];"? Why is it red? In 5.2, placing a semicolon at the
> end of Plot[] allowed me to output a plot in the middle of a computation,
> without halting the computation. Now I can no longer seem to output a plot
> in the middle of a long computation. (I only see the output of Print[]
> commands.) I must be able to see these plots during long computations, like
> I was able to in 5.2.
> 
> What's wrong? Can anyone please help?
> 
> Thanks,
> 
> Charlie
> 
> 

-- 
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


  • Prev by Date: Re: Inequalities or histogram or something.......
  • Next by Date: Re: Why don't my plots appear? My 5.2 code no longer works correctly in 6.0
  • Previous by thread: Re: Why don't my plots appear? My 5.2 code no longer works
  • Next by thread: Re: Why don't my plots appear? My 5.2 code no longer works correctly in 6.0