MathGroup Archive 2008

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

Search the Archive

ExtraAxes for Plot[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88367] ExtraAxes for Plot[]
  • From: roby.nowak at gmail.com
  • Date: Sat, 3 May 2008 06:15:46 -0400 (EDT)

Hello,

once again due to some formatting troubles when posting.
Any comments wellcome.

(* pacakgae 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\
[Rule]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\
[Rule]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[]


(* sample code *)

Plot[{Sin[x], 2 + Cos[x]}, {x, 0 \[Pi], 3 \[Pi]}, 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: Problem/bug with ends of thick lines in graphics
  • Next by Date: Re: DSolve Issues
  • Previous by thread: ExtraAxes for Plot[]
  • Next by thread: Bilateral cell problem w/ Manipulate