MathGroup Archive 2002

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

Search the Archive

RE: Plotting multiple functions with different plot ranges?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33562] RE: [mg33546] Plotting multiple functions with different plot ranges?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 31 Mar 2002 04:09:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

aes,

The easiest method is to make two plots and combine them. It is not tedious
if you use my DrawGraphics package available at my web site. In fact, that
was the principal motivation for the package.

Needs["DrawGraphics`DrawingMaster`"]

Draw2D[
    {Draw[Cos[x], {x, 0, 2Pi}],
     Blue, Draw[Sin[x], {x, Pi/2, 3Pi/2}]},
    Axes -> True
    ];

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



> -----Original Message-----
> From: aes [mailto:siegman at stanford.edu]
To: mathgroup at smc.vnet.net
> Sent: Friday, March 29, 2002 6:14 AM
> Subject: [mg33562] [mg33546] Plotting multiple functions with different plot
> ranges?
>
>
> Is there any approved way to plot multiple functions with
> different plot ranges
> in a single Plot command
>
> Suppose, e.g., I want to plot Cos[x] over the full range from 0
> to 2 Pi but
> Sin[x] only over the subrange from Pi.2 to 3Pi/2, with just one
> Plot command.
>
> My naive initial attempt, namely
>
>    Plot[{Cos[x], If[x > Pi/2 && x < 3Pi/2, Sin[x]]},  {x, 0, 2Pi},
>     PlotRange -> {{0, 2Pi}, {-1,1}},  PlotStyle -> Thickness[0.008]];
>
> does what's wanted but generates a lot of "Plot::plnr" error messages.
>
> Workarounds include:
>
> 1)  Turn Off the error messages (dangerous?)
>
> 2)  Add a second argument to the If[ ]  statement that sets the
> second function
> to some constant  c1  outside the desired subrange, i.e.
>
>    Plot[{Cos[x], If[x > Pi/2 && x < 3Pi/2, Sin[x], c1]}, {x, 0, 2Pi},
>     PlotRange -> {{0, 2Pi}, {-1,1}}, PlotStyle -> Thickness[0.008]];
>
> where  c1  could be 0 or a number that falls on an axis line or
> outside the
> PlotRange for the plot.
>
> (Doing this still gives unwanted vertical "jump lines" at the ends of the
> subrange, along with unwanted effects if line Thickness is increased).
>
> 3)  Make two Plots and combine using Show (tedious).
>
> 4)  Set second function value to Null outside the subrange?
> (doesn't seem to
> work).
>
> Other solutions?
>



  • Prev by Date: Re: MonomialQ
  • Next by Date: Re: MonomialQ
  • Previous by thread: Re: Plotting multiple functions with different plot ranges?
  • Next by thread: FullSimplify problem on Mathematica 4.1.2.0