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

label origin on plot

1,024 views
Skip to first unread message

von-hi...@osu.edu

unread,
Jun 1, 2005, 6:36:38 AM6/1/05
to
In a 2-dimensional plot, Mathematica typically does not label the
origin. I would like X=0 to be labeled as "0." Is this possible?

Bob Hanlon

unread,
Jun 2, 2005, 5:20:05 AM6/2/05
to
Use a Frame

Plot[x,{x,0,4},Frame->True,Axes->False];

or a text annotation

Plot[x,{x,0,4},
Epilog->{Text["0", {0,-0.25}]},
PlotRange->All];


Bob Hanlon

Jens-Peer Kuska

unread,
Jun 2, 2005, 5:23:07 AM6/2/05
to
Hi,

Plot[Sin[x], {x, -Pi, Pi}, Epilog -> {Text[x == 0,
{0, 0}, {-1, 1}]}]

Regards
Jens

"ptv-...@socilogy.osu.edu" <von-hi...@osu.edu>
schrieb im Newsbeitrag
news:d7k33m$ogj$1...@smc.vnet.net...

David Park

unread,
Jun 2, 2005, 5:26:55 AM6/2/05
to
I'm a little surprised. With a standard Axes plot it does not seem possible
to get the zero ticks labeled.

Plot[1 - x^2, {x, 0, 1}];

Extending the lower plot range and even explicitly labeling the ticks still
does not work.

Plot[1 - x^2, {x, 0, 1},
Ticks -> {Table[{i, i}, {i, 0, 1, 0.2}], Table[{i, i}, {i, 0, 1, 0.2}]},
PlotRange -> {{-0.05, 1}, {-0.05, 1}}];

But using a Frame (which is generally better anyway) and extending the lower
plot range will label the zero points.

Plot[1 - x^2, {x, 0, 1},
Frame -> True,
PlotRange -> {{-0.01, 1}, {-0.01, 1}}];

If you don't want to show the entire Frame you can use...

Plot[1 - x^2, {x, 0, 1},
Frame -> {True, True, False, False},
PlotRange -> {{-0.01, 1}, {-0.01, 1}}];

David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/

Selwyn Hollis

unread,
Jun 2, 2005, 5:27:41 AM6/2/05
to

On Jun 1, 2005, at 6:03 AM, ptv-...@socilogy.osu.edu wrote:

> In a 2-dimensional plot, Mathematica typically does not label the
> origin. I would like X=0 to be labeled as "0." Is this possible?
>

You can add it yourself by doing something like this:

Plot[x^2, {x, -1, 1}, Epilog -> Text[0, {0, -0.05}]]


--------------
Selwyn Hollis
http://www.appliedsymbols.com


Murray Eisenberg

unread,
Jun 3, 2005, 6:15:23 AM6/3/05
to
The method of showing part of a frame does not give felicitous results
if, e.g, the plot of 1 - x^2 is to be done on domain from -1 to 1.

If you open just about any calculus text, e.g., to a 2D graph plot,
you'll see axes going through the pont (0, 0) and with that point
labelled with a single 0. It's unfortunate that Mathematica does not
provide an option to Plot to reproduce this well-established behavior.
It's just plain annoying that one has to resort to the work-around of
using an Epilog with a Text primitive.


David Park wrote:
> I'm a little surprised. With a standard Axes plot it does not seem possible
> to get the zero ticks labeled.
>
> Plot[1 - x^2, {x, 0, 1}];
>
> Extending the lower plot range and even explicitly labeling the ticks still
> does not work.
>
> Plot[1 - x^2, {x, 0, 1},
> Ticks -> {Table[{i, i}, {i, 0, 1, 0.2}], Table[{i, i}, {i, 0, 1, 0.2}]},
> PlotRange -> {{-0.05, 1}, {-0.05, 1}}];
>
> But using a Frame (which is generally better anyway) and extending the lower
> plot range will label the zero points.
>
> Plot[1 - x^2, {x, 0, 1},
> Frame -> True,
> PlotRange -> {{-0.01, 1}, {-0.01, 1}}];
>
> If you don't want to show the entire Frame you can use...
>
> Plot[1 - x^2, {x, 0, 1},
> Frame -> {True, True, False, False},
> PlotRange -> {{-0.01, 1}, {-0.01, 1}}];
>
> David Park
> dj...@earthlink.net
> http://home.earthlink.net/~djmp/
>
>
> From: ptv-...@socilogy.osu.edu [mailto:von-hi...@osu.edu]
>
>

> In a 2-dimensional plot, Mathematica typically does not label the
> origin. I would like X=0 to be labeled as "0." Is this possible?
>
>
>
>
>

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

AES

unread,
Jun 3, 2005, 6:14:37 AM6/3/05
to
As an addendum to this thread, if you have a plot (framed or not) whose
x axis runs from -4 to 4, the -4 point will typically not be labelled
but the +4 point will be (and similarly for y axis).

A workaround for this is PlotRange->{{-4.001,4},{--}} and etc.

David Park

unread,
Jun 4, 2005, 3:12:40 AM6/4/05
to
Murray,

There is another way to 'trick' Mathematica into labeling zero on one of the
axes.

Plot[1 - x^2, {x, -1, 1},
AxesOrigin -> {0.000001, 0},
AxesLabel -> {x, y}];

Even if calculus books have such plots, I don't think they are so great. The
reason is that the ticks and the labeling come right in the middle of the
curve. I still think a Frame plot is better because it gets all of the
labeling off of the curve. The only technical magazine I have access to
today is Science magazine. (I used to be able to visit the NIST library,
which is not too far away, but now it is closed to the general public
because of paranoia.) As I have often remarked here, you will be hard
pressed to find an Axes plot in Science.

Murray Eisenberg

unread,
Jun 4, 2005, 3:14:57 AM6/4/05
to
That technique of putting the axis origin very close to, but not at, 0
is work-around to what I consider a Mathematica design deficiency,
namely, not including an option to allow labelling the origin.

I quite agree that axes through the origin is NOT what one typically
sees in science graphs. The fact remains that axes with the origin
labelled with a single 0 is a long-standing convention in mathematics.
(And yes, that can lead to all sorts of clashes of the function graph
with the tick labels, and not just that at 0.)

One should not underestimate the importance of historical convention in
such matters. After all, a very good case can be made that conventional
mathematical notation is really quite bad -- replete with ambiguities
and inconsistencies -- but to the disappointment of some, an
unambiguous, totally consistent mathematical notation (e.g., that
introduced by K. Iverson) has never made any significant and permanent
inroad into the conventional notation.

David Park wrote:

> There is another way to 'trick' Mathematica into labeling zero on one of the
> axes.
>
> Plot[1 - x^2, {x, -1, 1},
> AxesOrigin -> {0.000001, 0},
> AxesLabel -> {x, y}];
>
> Even if calculus books have such plots, I don't think they are so great. The
> reason is that the ticks and the labeling come right in the middle of the
> curve. I still think a Frame plot is better because it gets all of the

> labeling off of the curve. ... As I have often remarked here, you will be hard


> pressed to find an Axes plot in Science.

--

Kevin J. McCann

unread,
Jun 7, 2005, 2:10:41 AM6/7/05
to
I usually just use something like this
PlotRange->{{-0.0001,10},{-0.0001,10}}

It is a kludge, but it works.

Kevin

0 new messages