This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
Wolfram Research, Inc.

Coordinate Systems for Two-Dimensional GraphicsMaking Plots within Plots

2.9.5 Labeling Two-Dimensional Graphics

Ways to label two-dimensional plots.

Here is a plot, using the default Axes -> True.

In[1]:= bp = Plot[BesselJ[2, x], {x, 0, 10}]

Out[1]=

Setting Frame -> True generates a frame with axes, and removes tick marks from the ordinary axes.

In[2]:= Show[bp, Frame -> True]

Out[2]=

This includes grid lines, which are shown in light blue on color displays.

In[3]:= Show[%, GridLines -> Automatic]

Out[3]=

Options for axes.

This makes the axes cross at the point {5, 0}, and puts a label on each axis.

In[4]:= Show[bp, AxesOrigin->{5, 0}, AxesLabel->{"x", "y"}]

Out[4]=

Settings for the Ticks option.

With the default setting Ticks -> Automatic, Mathematica creates a certain number of major and minor tick marks, and places them on axes at positions which yield the minimum number of decimal digits in the tick labels. In some cases, however, you may want to specify the positions and properties of tick marks explicitly. You will need to do this, for example, if you want to have tick marks at multiples of , or if you want to put a nonlinear scale on an axis.

Tick mark options for each axis.

This gives tick marks at specified positions on the axis, and chooses the tick marks automatically on the axis.

In[5]:= Show[bp, Ticks -> {{0, Pi, 2Pi, 3Pi}, Automatic}]

Out[5]=

This adds tick marks with no labels at multiples of .

In[6]:= Show[bp,

Ticks -> {{0, {Pi/2, ""}, Pi, {3Pi/2, ""},

2Pi, {5Pi/2, ""}, 3Pi}, Automatic}]

Out[6]=

Particularly when you want to create complicated tick mark specifications, it is often convenient to define a "tick mark function" which creates the appropriate tick mark specification given the minimum and maximum values on a particular axis.

This defines a function which gives a list of tick mark positions with a spacing of 1.

In[7]:= units[xmin_, xmax_] :=

Range[Floor[xmin], Floor[xmax], 1]

This uses the units function to specify tick marks for the axis.

In[8]:= Show[bp, Ticks -> {units, Automatic}]

Out[8]=

Sometimes you may want to generate tick marks which differ only slightly from those produced automatically with the setting Ticks -> Automatic. You can get the complete specification for tick marks that were generated automatically in a particular plot by using AbsoluteOptions[g, Ticks], as discussed in Section 2.9.1.

Options for frame axes.

The Axes option allows you to draw a single pair of axes in a plot. Sometimes, however, you may instead want to show the scales for a plot on a frame, typically drawn around the whole plot. The option Frame allows you effectively to draw four axes, corresponding to the four edges of the frame around a plot. These four axes are ordered clockwise, starting from the one at the bottom.

This draws frame axes, and labels each of them.

In[9]:= Show[bp, Frame -> True,

FrameLabel -> {"label 1", "label 2",

"label 3", "label 4"}]

Out[9]=

Options for grid lines.

Grid lines in Mathematica work very much like tick marks. As with tick marks, you can specify explicit positions for grid lines. There is no label or length to specify for grid lines. However, you can specify a style.

This generates but not grid lines.

In[10]:= Show[bp, GridLines -> {Automatic, None}]

Out[10]=

Coordinate Systems for Two-Dimensional GraphicsMaking Plots within Plots