How to | Display and Style Data Points on a 2D Curve
When plotting curves from data, there are several methods you can use to display the data points along the curve. While the default settings for displaying such plots are suitable in most cases,
Mathematica also includes options that allow you to style the curves and data points as you wish.
ListLinePlot and
ListPlot can create 2D curves from lists of data.
First, define some data to plot:
ListPlot is most commonly used to create scatter plots from lists of data. By default,
ListPlot does not join the data points with a line:
| Out[4]= |  |
ListLinePlot is used to plot a line between a list of values. By default,
Mathematica does not draw points on curves created by
ListLinePlot:
| Out[8]= |  |
You can display the data points along the curves with the
PlotMarkers or
Mesh options:
| Out[9]= |  |
| Out[10]= |  |
Use the
PlotStyle option with
Mesh to change the color of each curve:
| Out[11]= |  |
Use the
PlotStyle option with
PlotMarkers to change the color of each curve and its points. Note that the result of
PlotStyle here is different from when
PlotStyle was used with
Mesh:
| Out[12]= |  |
Similar to
PlotStyle, the
MeshStyle option lets you use graphics directives to style the points in a plot. You must also use
Mesh to be able to use
MeshStyle:
| Out[13]= |  |
You cannot use
Mesh or
MeshStyle to change the type of points in a plot. You must use
PlotMarkers to do this:
| Out[14]= |  |
You can use
Mesh and
PlotMarkers together, but points created by
PlotMarkers take precedence over those created by
Mesh:
| Out[15]= |  |
As long as
Mesh is used, you can still style the points with
MeshStyle:
| Out[16]= |  |
The styling techniques shown here will also work on curves drawn by
ListPlot.
Mathematica can also display points in 3D plots. For example, you may wish to view the underlying data points of this 3D surface generated by
ListPlot3D:
| Out[66]= |  |
Use
ListPointPlot3D to do this:
| Out[67]= |  |