MathGroup Archive 2002

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

Search the Archive

Re: newbie question - plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33430] Re: newbie question - plot
  • From: phbrf at t-online.de (Peter Breitfeld)
  • Date: Thu, 21 Mar 2002 09:27:09 -0500 (EST)
  • References: <a76g9i$gn3$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mateusz schrieb:
> Hello,
> 
> What option should I use with the "Plot" command in order to obtain arrows
> for x's and y's.
> I mean: I want axes to be ended with arrows. Help me please. :)
> 
> Mateusz
> 
You could use the following:

----------------8<----------------8<---------------- 
PfeileAnAchsen::usage= "PfeileAnAchsen[graphic] nimmt eine 2D-Graphik
`graphic' und setzt Pfeile an das Ende der Achsen. Falls die
Originalgraphik keine Achsen besitzt, werden welche erzeugt.\n
PfeileAnAchsen[graphic, frac] setzt die Länge der Pfeile auf den
Bruchteil `frac' der Länge der Achsen und hängt sie an die Achsen an.
Defaultwert für `frac' ist 1/15.\n PfeileAnAchsen[graphik, frac, opts]
erlaubt Optionen für die Pfeile mitzugeben. Diese Optionen sind Optionen
von `Arrow'. Default ist HeadCenter->0.7 und HeadWidth->0.32."

Options[PfeileAnAchsen]=Options[Arrow];
SetOptions[PfeileAnAchsen,HeadCenter->0.7,HeadWidth->0.32];
PfeileAnAchsen::whoops= "Das erste Argument von `PfeileAnAchsen' muss
eine 2D-Graphik mit Head Graphics sein."

PfeileAnAchsen[pl_,(frac:(_?NumberQ):1/15),opts___?OptionQ]/;
      Head[pl]===Graphics||Message[ToArrowAxes::whoops]:=
Module[{x0,y0,xi,xf,yi,yf,xdelta,ydelta,xfarrow,yfarrow,prim,gopts,hcopt},
  hcopt=HeadCenter/.{opts}/.Options[PfeileAnAchsen];
  {{xi,xf},{yi,yf}}=PlotRange/.AbsoluteOptions[pl,PlotRange];
  {x0,y0}=AxesOrigin/.AbsoluteOptions[pl,AxesOrigin];
  xdelta=(xf-xi)frac;
  ydelta=(yf-yi)frac;;
  xfarrow=Arrow[{xf,y0}, {xf+xdelta,y0},HeadCenter->hcopt,opts];
  yfarrow=Arrow[{x0,yf}, {x0,yf+ydelta},HeadCenter->hcopt,opts];
  Show[
     Graphics[{xfarrow,yfarrow},
        PlotRange->{{xi,xf+xdelta},{yi,yf+ydelta}}],
        FullGraphics[
          pl/.Graphics[prim:{___},gopts_]:>
              Graphics[prim,Axes->True,gopts]],
        DisplayFunction->$DisplayFunction]
];
----------------8<----------------8<---------------- 
Sorry for the german.

Then all you have to do ist e.g.

In[1]= pl=Plot[....]

In[2]= PfeileAnAchsen[pl]

you will need the Arrow-Package.

Gruß Peter
-- 
=--=--=--=--=--=--=--=--=--=--=--=--=--= http://home.t-online.de/home/phbrf
 Peter Breitfeld, Bad Saulgau, Germany   Meinen GnuPG/PGP-5x Key gibts dort



  • Prev by Date: Re: Value and position in list
  • Next by Date: Re: Re: Full text of the current warning message(s)
  • Previous by thread: Re: newbie question - plot
  • Next by thread: Full text of the current warning message(s)