Labeling Two-Dimensional Graphics

Ways to label two-dimensional plots.

Here is a plot, using the default (RefLink[Axes, paclet:ref/Axes])->(RefLink[True, paclet:ref/True]):

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

Setting (RefLink[Frame, paclet:ref/Frame])->(RefLink[True, paclet:ref/True]) generates a frame with axes, and removes tick marks from the ordinary axes:

Show[bp,Frame->True]

This includes grid lines, which are shown in light gray:

Show[%,GridLines->Automatic]

Options for axes.

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

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

Settings for the (RefLink[Ticks, paclet:ref/Ticks]) option.

With the default setting (RefLink[Ticks, paclet:ref/Ticks])->(RefLink[Automatic, paclet:ref/Automatic]), the Wolfram Language 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 x axis, and chooses the tick marks automatically on the y axis:

Show[bp,Ticks->{{0,Pi,2Pi,3Pi},Automatic}]

This adds tick marks with no labels at multiples of π/2:

Show[bp,Ticks->{{0,{Pi/2,""},Pi,{3Pi/2,""},2Pi,{5Pi/2,""},3Pi},Automatic}]

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:

units[xmin_,xmax_]:=Range[Floor[xmin],Floor[xmax],1]

This uses the units function to specify tick marks for the x axis:

Show[bp,Ticks->{units,Automatic}]

Options for frame axes.

The (RefLink[Axes, paclet:ref/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 (RefLink[Frame, paclet:ref/Frame]) allows you effectively to draw four axes, corresponding to the four edges of the frame around a plot.

This draws frame axes, and labels each of them:

Show[bp,Frame->True,FrameLabel->{{"left label","right label"},{"bottom label","top label"}}]

Options for grid lines.

Grid lines in the Wolfram Language 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 x but not y grid lines:

Show[bp,GridLines->{Automatic,None}]