Options for Graphics

When Mathematica plots a graph for you, it has to make many choices. It has to work out what the scales should be, where the function should be sampled, how the axes should be drawn, and so on. Most of the time, Mathematica will probably make pretty good choices. However, if you want to get the very best possible pictures for your particular purposes, you may have to help Mathematica in making some of its choices.

There is a general mechanism for specifying "options" in Mathematica functions. Each option has a definite name. As the last arguments to a function like Plot, you can include a sequence of rules of the form , to specify the values for various options. Any option for which you do not give an explicit rule is taken to have its "default" value.

Plot[f,{x,xmin,xmax},option->value]make a plot, specifying a particular value for an option

Choosing an option for a plot.

A function like Plot has many options that you can set. Usually you will need to use at most a few of them at a time. If you want to optimize a particular plot, you will probably do best to experiment, trying a sequence of different settings for various options.

Each time you produce a plot, you can specify options for it. "Redrawing and Combining Plots" will also discuss how you can change some of the options, even after you have produced the plot.

option name
default value
AspectRatio1/GoldenRatiothe height-to-width ratio for the plot; Automatic sets it from the absolute and coordinates
AxesTruewhether to include axes
AxesLabelNonelabels to be put on the axes; ylabel specifies a label for the axis, for both axes
AxesOriginAutomaticthe point at which axes cross
BaseStyle{}the default style to use for the plot
FormatTypeTraditionalFormthe default format type to use for text in the plot
FrameFalsewhether to draw a frame around the plot
FrameLabelNonelabels to be put around the frame; give a list in clockwise order starting with the lower axis
FrameTicksAutomaticwhat tick marks to draw if there is a frame; None gives no tick marks
GridLinesNonewhat grid lines to include; Automatic includes a grid line for every major tick mark
PlotLabelNonean expression to be printed as a label for the plot
PlotRangeAutomaticthe range of coordinates to include in the plot; All includes all points
TicksAutomaticwhat tick marks to draw if there are axes; None gives no tick marks

Some of the options for Plot. These can also be used in Show.

Here is a plot with all options having their default values.
In[1]:=
Click for copyable input
Out[1]=
This draws axes on a frame around the plot.
In[2]:=
Click for copyable input
Out[2]=
This specifies labels for the and axes. The expressions you give as labels are printed just as they would be if they appeared as TraditionalForm Mathematica output. You can give any piece of text by putting it inside a pair of double quotes.
In[3]:=
Click for copyable input
Out[3]=
You can give several options at the same time, in any order.
In[4]:=
Click for copyable input
Out[4]=
Setting the AspectRatio option changes the whole shape of your plot. AspectRatio gives the ratio of width to height. Its default value is the inverse of the Golden Ratio—supposedly the most pleasing shape for a rectangle.
In[5]:=
Click for copyable input
Out[5]=
Automaticuse internal algorithms
Nonedo not include this
Allinclude everything
Truedo this
Falsedo not do this

Some common settings for various options.

When Mathematica makes a plot, it tries to set the and scales to include only the "interesting" parts of the plot. If your function increases very rapidly, or has singularities, the parts where it gets too large will be cut off. By specifying the option PlotRange, you can control exactly what ranges of and coordinates are included in your plot.

Automaticshow at least a large fraction of the points, including the "interesting" region (the default setting)
Allshow all points
{ymin,ymax}show a specific range of values
{xrange,yrange}show the specified ranges of and values

Settings for the option PlotRange.

The setting for the option PlotRange gives explicit limits for the graph. With the limits specified here, the bottom of the curve is cut off.
In[6]:=
Click for copyable input
Out[6]=

Mathematica always tries to plot functions as smooth curves. As a result, in places where your function wiggles a lot, Mathematica will use more points. In general, Mathematica tries to adapt its sampling of your function to the form of the function. There is a limit, however, which you can set, to how finely Mathematica will ever sample a function.

The function wiggles infinitely often when . Mathematica tries to sample more points in the region where the function wiggles a lot, but it can never sample the infinite number that you would need to reproduce the function exactly. As a result, there are slight glitches in the plot.
In[7]:=
Click for copyable input
Out[7]=

It is important to realize that since Mathematica can only sample your function at a limited number of points, it can always miss features of the function. Mathematica adaptively samples the functions, increasing the number of samples near interesting features, but it is still possible to miss something. By increasing PlotPoints, you can make Mathematica sample your function at a larger number of points. Of course, the larger you set PlotPoints to be, the longer it will take Mathematica to plot any function, even a smooth one.

option name
default value
PlotStyleAutomatica list of lists of graphics primitives to use for each curve (see "Graphics Directives and Options")
ClippingStyleNonewhat to draw when curves are clipped
FillingNonefilling to insert under each curve
FillingStyleAutomaticstyle to use for filling
PlotPoints50the initial number of points at which to sample the function
MaxRecursionAutomaticthe maximum number of recursive subdivisions allowed

More options for Plot. These cannot be used in Show.

This uses PlotStyle to specify a dashed curve.
In[8]:=
Click for copyable input
Out[8]=
When plotting multiple functions, PlotStyle settings in a list are used sequentially for each function.
In[9]:=
Click for copyable input
Out[9]=
When a PlotStyle contains a sublist, the settings are combined.
In[10]:=
Click for copyable input
Out[10]=
By default nothing is indicated when the PlotRange is set, so that it cuts off curves.
In[11]:=
Click for copyable input
Out[11]=
Setting ClippingStyle to Automatic draws a dashed line where a curve is cut off.
In[12]:=
Click for copyable input
Out[12]=
Setting ClippingStyle to a list defines the style for the parts cut off at the bottom and top.
In[13]:=
Click for copyable input
Out[13]=
This specifies filling between the curve and the axis.
In[14]:=
Click for copyable input
Out[14]=
The filling can be specified to extend to an arbitrary height, such as the bottom of the graphic. Filling colors are automatically blended where they overlap.
In[15]:=
Click for copyable input
Out[15]=
This specifies a specific filling to be used only for the first curve.
In[16]:=
Click for copyable input
Out[16]=
This shows a filling from the first curve to the second using a nondefault filling style.
In[17]:=
Click for copyable input
Out[17]=
New to Mathematica? Find your learning path »
Have a question? Ask support »