MathGroup Archive 1996

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

Search the Archive

Re: [Q] Plotting non-continuous function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4478] Re: [Q] Plotting non-continuous function
  • From: rubin at msu.edu (Paul A. Rubin)
  • Date: Mon, 29 Jul 1996 02:37:29 -0400
  • Organization: Michigan State University
  • Sender: owner-wri-mathgroup at wolfram.com

In article <4s4itn$9ud at dragonfly.wolfram.com>,
   pherron at GSB-Pound.Stanford.EDU (Michael C. Herron) wrote:
->
->Suppose I have defined:
->
->f[x_] := Which [x<=5,2,True,10]
->
->If I then do Plot [f[t],{t,0,20}], the resulting graphic has a
->vertical line at x=5.  Is there anyway to avoid this?  Ideally, I
->would like the plot to have an open ball on the line y=2 and a closed
->ball at y=10 to indicate that the function at x=5 has a limit from the
->right but not from the left.  Is it possible to do this?  If the
->answer is in a mathematica book, I would like a reference.
->
->Thanks.
->
->Michael

You can always split the function into two separate functions:

In[]:=  f1[ x_ ] := 2 /; x <= 5
        f2[ x_ ] := 10 /; x >= 5

In[]:=  p = Plot[ {f1[x], f2[x]}, {x, 0, 10}, PlotRange -> {0, 12}, 
                  DisplayFunction -> Identity ];
Out[]=  Plot::plnr: 
          CompiledFunction[{x}, <<1>>, <<13>>-][x]
          is not a machine-size real number at x = 5.41667.

<This highly ignorable error message gets repeated a few times.>

In[]:=  g = Graphics[ {Circle[ {5, 2}, .2 ], Disk[ {5, 10}, .2 ]} ];

In[]:=  Show[ p, g, DisplayFunction -> $DisplayFunction, 
              AspectRatio -> Automatic ];

Paul


**************************************************************************
* Paul A. Rubin                                  Phone: (517) 432-3509   *
* Department of Management                       Fax:   (517) 432-1111   *
* Eli Broad Graduate School of Management        Net:   RUBIN at MSU.EDU    *
* Michigan State University                                              *
* East Lansing, MI  48824-1122  (USA)                                    *
**************************************************************************
Mathematicians are like Frenchmen:  whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different.                                    J. W. v. GOETHE

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Exporting and Editing MMA Graphics?
  • Next by Date: lost connection to license server
  • Previous by thread: [Q] Plotting non-continuous function
  • Next by thread: a question on ContourPlot