MathGroup Archive 2010

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

Search the Archive

Re: Change position of axes label

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109249] Re: Change position of axes label
  • From: "David Park" <djmpark at comcast.net>
  • Date: Mon, 19 Apr 2010 02:49:28 -0400 (EDT)

Essential you can "roll your own" labels by using Text statements "outside
the Frame". In order to make this work you need to:
1) Set PlotRangeClipping -> False.
2) Specify ImagePadding large enough to provide room for the labels (and
tick values also).
3) Specify the label(s) in an Epilog option.

Plot[x^2, {x, -2.5, 2.5},
 Frame -> True,
 PlotRange -> {-0.012, 0.012},
 AxesLabel -> {"label 1", None},
 Epilog -> {Text["label 2", {-2.5, 0.0135}]},
 PlotRangeClipping -> False,
 ImagePadding -> {{50, 50}, {20, 20}}] 

The following draws both labels using the Epilog statement.

Plot[x^2, {x, -2.5, 2.5},
 Frame -> True,
 PlotRange -> {-0.012, 0.012},
 Epilog ->
  {Text["label 1", {2.7, 0}, {-1, 0}],
   Text["label 2", {-2.5, 0.0135}]},
 PlotRangeClipping -> False,
 ImagePadding -> {{50, 50}, {20, 20}}] 


One of the minor problems with normal Frame labels is that the bottom label
is often too far from the frame. This kind of custom labeling can solve the
problem.

For those who have Presentations you don't have to use Epilog but can
include the Text labels in the list of items to be drawn. But there is a
caveat because we don't want the parabola to be drawn outside the frame,
which the PlotRangeClipping option would now allow, so we have to include a
PlotRange option in the Draw statement. In this example I place the bottom
label under, but close to the frame - just as an example.

Needs["Presentations`Master`"] 

Draw2D[
 {Draw[x^2, {x, -2.5, 2.5}, PlotRange -> {-0.012, 0.012}],
  Text["label 1", {1.5, -0.0135}],
  Text["label 2", {-2.5, 0.0135}]},
 AspectRatio -> .6,
 Frame -> True, Axes -> True,
 PlotRange -> {{-2.5, 2.5}, {-0.012, 0.012}},
 PlotRangeClipping -> False,
 ImagePadding -> {{50, 10}, {40, 20}}] 


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  



From: Jim Lambaugh [mailto:lambaugh at gmail.com] 

Hi

I have the following plot

Plot[x^2, {x, -2.5, 2.5},
 Frame -> True,
 PlotRange -> {-0.012, 0.012},
 AxesLabel -> {"label 1", "label 2"}]

Is it possible to move "label 2" such that it stands right above the
vertical axis? I.e., I want to move "label 2" to the left. The
position of "label 1" is perfect.

Any advice?

Best regards,
Jimmy.




  • Prev by Date: Volcanic Ash Cloud over Europe in 14 lines of Mathematica
  • Next by Date: Re: ArrayPlot coordinates scaling for overlays
  • Previous by thread: Re: Change position of axes label
  • Next by thread: Re: Change position of axes label