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:
ListLinePlot is used to plot a line between a list of values. By default, Mathematica does not draw points on curves created by ListLinePlot:
You can display the data points along the curves with the PlotMarkers or Mesh options:
Use the PlotStyle option with Mesh to change the color of each curve:
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:
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:
You cannot use Mesh or MeshStyle to change the type of points in a plot. You must use PlotMarkers to do this:
You can use Mesh and PlotMarkers together, but points created by PlotMarkers take precedence over those created by Mesh:
As long as Mesh is used, you can still style the points with MeshStyle:
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:
Use ListPointPlot3D to do this: