Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

discontinuous 3D plot and error messages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25050] discontinuous 3D plot and error messages
  • From: PNichols at cornell-iowa.edu
  • Date: Sun, 3 Sep 2000 22:11:08 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Mathematica programming experts,

I've come across a question about handling Mathematica's error messages, and
I'm a little surprised  that I've never come across the answer before.

Here's the question:  I want to turn off the Plot3D::plnc message while a
function I've written does its work, and then leave the message in its
previous state (whether on or off) when the function is finished.  To do
this, I came up with the following construction:

Module[{plncHead,...},
  plncHead = Head[Plot3D::plnc]; (* record the prior state *)
  Off[Plot3D::plnc]; (* turn it off *)
  ...(* the main code *)
  If[plncHead =!= $Off, On[Plot3D::plnc]]; (* if it was on before, turn it
back on *)
  Show[...]
]

Is there a better way to do this?  What's the accepted view about functions
that "secretly" turn standard messages on or off?

===========================================================

Here are the details of the context for this question:

A few weeks ago, Ulrich Bodenhofer asked about 3D plots of functions having
discontinuities along lines and curves, and Andrzej Kozlowski suggested a
method based on DeleteCases.  I tried it out and liked it enough to build it
into a PlotDiscontinuous3D function so I can use it later, with my
undergraduate course in multivariable calculus.  Here it is:

Needs["Utilities`FilterOptions`"];

PlotDiscontinuous3D::usage =
"PlotDiscontinuous3D[funclist,{x,xmin,xmax},{y,ymin,ymax}] plots a
discontinuous function of x and y.  The first argument funclist should be a
list of pairs of the form {cond,expr}, where cond and expr are both
expressions in x and y, and expr is to be plotted for those values of x and
y which make cond True.";

PlotDiscontinuous3D[pieces_,{x_,xmin_,xmax_},{y_,ymin_,ymax_},opts___]:=
  Module[{plncHead, filledpieces, plots},
    plncHead = Head[Plot3D::plnc]; Off[Plot3D::plnc];
    filledpieces = Apply[If[##1, Indeterminate]&, pieces, {1}]; 
    Block[{$DisplayFunction = Identity}, 
      plots = (Plot3D[#, {x,xmin,xmax}, {y,ymin,ymax},
        Evaluate[FilterOptions[Plot3D, opts]]]&) /@ filledpieces];
    plots = Graphics3D /@ plots;
    plots = DeleteCases[plots,
      {_, _, _}?(MemberQ[#1, Indeterminate]&), Infinity];
    If[plncHead =!= $Off, On[Plot3D::plnc]];
    Show[plots, Evaluate[FilterOptions[Graphics3D, opts]] ]
  ]

If you set PlotPoints fairly high and Mesh->False, the results are okay,
though still not as good as David Park's method of customized coordinate
transformations.  Here's an example:

PlotDiscontinuous3D[{{x^2 + y^2 <= 2, x^2 + y^2 + 2}, 
    {x^2 + y^2 > 2, Sin[(x^2 + y^2)/2]}},
    {x, -3, 3}, {y, -3, 3},
    PlotPoints -> 75, Mesh -> False]; 


Preston Nichols
Mathematics Departement
Cornell College


  • Prev by Date: Re: Simple integral wrong
  • Next by Date: Re: plotsymbol
  • Previous by thread: RE Looking for a faster way
  • Next by thread: Re: Email