How to | Make a Smoother or Rougher Plot

Mathematica gives you the ability to fine-tune the level of detail for your plots. To get a rough sketch of a plot, you can tell Mathematica to plot fewer points. The more points you have in a plot, the more detailed the results will be.

First, plot a simple function:

In[1]:=
Click for copyable input
Out[1]=

Set the option Mesh->All to see the default sample points that Mathematica uses:

In[2]:=
Click for copyable input
Out[2]=

You can adjust the number of sample points plotted with PlotPoints. MaxRecursion controls how many recursive subdivisions can be made:

Setting values for PlotPoints and MaxRecursion high makes a very detailed picture at the cost of speed. AbsoluteTiming prints how long (in seconds) it takes to evaluate:

In[4]:=
Click for copyable input
Out[4]=

Smaller values for PlotPoints and MaxRecursion give a rougher but much faster result:

In[5]:=
Click for copyable input
Out[5]=

You can get a misleading result if these parameter values are chosen poorly. This is the accurate plot produced by Mathematica's default settings:

In[6]:=
Click for copyable input
Out[6]=

Setting PlotPoints too low yields a misleading result:

In[7]:=
Click for copyable input
Out[7]=

You can compensate for a low PlotPoints value by increasing MaxRecursion, but this will often take much longer, and may still be inaccurate:

In[8]:=
Click for copyable input
Out[8]=
New to Mathematica? Find your learning path »
Have a question? Ask support »