Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

ExtraAxes for Plot[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88324] ExtraAxes for Plot[]
  • From: roby.nowak at gmail.com
  • Date: Thu, 1 May 2008 06:28:24 -0400 (EDT)

Dear all,

maybe this is valuable for some of you.
Below you can find a Mathematica Package containing 2 Functions one for
additional X-Axes generation and one for Y-Axes.

The additional Axes are included in the Epilog of Plot.
Plot[......,
Epilog -> {..., ExtraXAxes[......], ...}
]

Multiple Axes in both directions can be specifyed.

Standard Mathematica Axes Options such as TicksStyle or AxesStyle can be used.


Below the Package you can find an example


(* start of package code *)

BeginPackage["ExtraAxes`"]
ExtraXAxes::usage="ExtraXAxes[{FromTick, ToTick, TickStep},
{InsertStartPos,InsertEndPos},YInsertPos]"<>"\n"<>
	"\tGenerates an additional X-Axes with range FromTick to ToTick and
step TickStep."<>"\n"<>
	"\tThe additional Axes is inserted from x: InsertStartPos to
InsertEndPos at y: YInsertPos."<>"\n"<>
	"\tOptions can be passed e.g. TicksStyle-
>Directive[{Blue,Thick}]"<>"\n"<>
	"\tInclude the additional Axes by means of Epilog->ExtraXAxes[]"
ExtraYAxes::usage="ExtraYAxes[{FromTick, ToTick, TickStep},
{InsertStartPos,InsertEndPos},XInsertPos]"<>"\n"<>
	"\tGenerates an additional Y-Axes with range FromTick to ToTick and
step TickStep."<>"\n"<>
	"\tThe additional Axes is inserted from y: InsertStartPos to
InsertEndPos at x: XInsertPos."<>"\n"<>
	"\tOptions can be passed e.g. TicksStyle-
>Directive[{Blue,Thick}]"<>"\n"<>
	"\tInclude the additional Axes by means of Epilog->ExtraYAxes[]"

Begin["`Private`"]
ExtraXAxes[{from_,to_,step_},{xpos_,xend_},ypos_,opts_:{}]:=
	Graphics[{},AspectRatio->Full,ImagePadding->0,Axes-
>{True,False},Sequence@opts,
	PlotRange->{{from-1/2 step,to+1/2 step},0{-1,1}},Ticks->{Table[i,
{i,from,to,step}],None}]//Inset[#,{xpos,ypos},{from,0},((step (xend-
xpos))/(to-from)+xend-xpos){1,1}]&
ExtraYAxes[{from_,to_,step_},{ypos_,yend_},xpos_,opts_:{}]:=
	Graphics[{},AspectRatio->Full,ImagePadding->0,Axes-
>{False,True},Sequence@opts,
	PlotRange->{0{-1,1},{from-1/2 step,to+1/2 step}},Ticks->{None,Table[i,
{i,from,to,step}]}]//Inset[#,{xpos,ypos},{0,from},((step (yend-ypos))/
(to-from)+yend-ypos){1,1}]&
End[]
EndPackage[]


(* start sample test code *)

Plot[{Sin[x],2+Cos[x]},{x,0\[Pi],3\[Pi]},ImageSize->600,PlotRange-
>All,PlotStyle->{Black,Blue},
Epilog->{ExtraXAxes[{1/2\[Pi],3/2\[Pi],\[Pi]/8},{1/2\[Pi],3/2\[Pi]},
2,TicksStyle->Directive[Darker@Magenta,Italic,
Bold]],ExtraYAxes[{-150,350,50},{-1.5,3.5},8,{TicksStyle-
>Directive[Blue,Large],AxesStyle->Directive[Orange,Thick]}]}]


  • Prev by Date: Mathematica student certification now available
  • Next by Date: Re: Assigning multiple variables within a Block[] statement (e.g.
  • Previous by thread: Re: Mathematica student certification now available
  • Next by thread: ExtraAxes for Plot[]