Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: Axes with arrowheads !?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65598] Re: Axes with arrowheads !?
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Mon, 10 Apr 2006 02:31:18 -0400 (EDT)
  • References: <e1ah86$1q0$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

luis.riegger at gmail.com schrieb:
> how can i do that !?!
>

I don't know, if this is good code, but it works:

Needs["Graphics`Arrow"]

Options[PfeileAnAchsen]=Options[Arrow];

SetOptions[PfeileAnAchsen,HeadCenter->0.7,HeadWidth->0.32];

PfeileAnAchsen::whoops=
"First argument of \"PfeileAnAchsen\" must have Head Graphics."

PfeileAnAchsen[pl_,(frac:(_?NumberQ):1/15),opts___?OptionQ]/;
      Head[pl]===Graphics||Message[PfeileAnAchsen::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]
];

Now you may call it like this:

gr=Plot[Sin[x],{x,-Pi,2Pi}];
PfeileAnAchsen[gr]

or even

PfeileAnAchsen[Plot[Sin[x],{x,-Pi,2Pi},DisplayFunction->Identity]]


Gruss Peter
-- 
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de




  • Prev by Date: Re: HoldFirst question
  • Next by Date: Re: Help with Identities
  • Previous by thread: Re: Axes with arrowheads !?
  • Next by thread: Re: Re: Axes with arrowheads !?