Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change position of axes label

3,397 views
Skip to first unread message

Jim Lambaugh

unread,
Apr 18, 2010, 5:56:58 AM4/18/10
to
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.

Tyler

unread,
Apr 19, 2010, 2:49:06 AM4/19/10
to

Is this acceptable?

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

That is, add a space or two at the beginning of label 2....

Cheers,

t.

David Park

unread,
Apr 19, 2010, 2:49:17 AM4/19/10
to
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
djm...@comcast.net
http://home.comcast.net/~djmpark/

From: Jim Lambaugh [mailto:lamb...@gmail.com]

Hi

I have the following plot

Plot[x^2, {x, -2.5, 2.5},

Alexei Boulbitch

unread,
Apr 19, 2010, 5:58:52 AM4/19/10
to
Hi, Jimmy,
try this:

Plot[x^2, {x, -2.5, 2.5}, Frame -> True, PlotRange -> {-0.012, 0.012},

AxesLabel -> {"label 1", Row[{"label 2", Spacer[229]}]}]

Would not be more comfortable to use FrameLabel instead of AxesLabel in this case?

Have fun, Alexei


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.


--
Alexei Boulbitch, Dr., habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax: +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.

0 new messages