ListPlot

ListPlot[{y1,y2,}]
plots points {1,y1},{2,y2},.

ListPlot[{{x1,y1},{x2,y2},}]
plots a list of points with specified x and y coordinates.

ListPlot[{data1,data2,}]
plots data from all the datai.

ListPlot[{,w[datai,],}]
plots datai with features defined by the symbolic wrapper w.

Details and OptionsDetails and Options

  • Data values xi and yi can be given in the following forms:
  • xia real-valued number
    Quantity[xi,unit]a quantity with a unit
  • Values xi and yi that are not of the form above are taken to be missing and are not shown.
  • The datai have the following forms and interpretations:
  • <|"k1"y1,"k2"y2,|>values {y1,y2,}
    <|x1y1,x2y2,|>key-value pairs {{x1,y1},{x2,y2},}
    {y1"lbl1",y2"lbl2",}, {y1,y2,}{"lbl1","lbl2",}values {y1,y2,} with labels {lbl1,lbl2,}
    SparseArrayvalues as a normal array
    TimeSeries, EventSeriestime-value pairs
    QuantityArraymagnitudes
    WeightedDataunweighted values
  • The following wrappers w can be used for the datai:
  • Annotation[datai,label]provide an annotation for the data
    Button[datai,action]define an action to execute when the data is clicked
    Callout[datai,label]label the data with a callout
    Callout[datai,label,pos]place the callout at relative position pos
    EventHandler[datai,]define a general event handler for the data
    Hyperlink[datai,uri]make the data a hyperlink
    Labeled[datai,label]label the data
    Labeled[datai,label,pos]place the label at relative position pos
    Legended[datai,label]identify the data in a legend
    PopupWindow[datai,cont]attach a popup window to the data
    StatusArea[datai,label]display in the status area on mouseover
    Style[datai,styles]show the data using the specified styles
    Tooltip[datai,label]attach a tooltip to the data
    Tooltip[datai]use data values as tooltips
  • Wrappers w can be applied at multiple levels:
  • {,w[yi],}wrap the value yi in data
    {,w[{xi,yi}],}wrap the point {xi,yi}
    w[datai]wrap the data
    w[{data1,}]wrap a collection of datai
    w1[w2[]]use nested wrappers
  • Callout, Labeled, and Placed can use the following positions pos:
  • Automaticautomatically placed labels
    Above, Below, Before, Afterpositions around the data
    xnear the data at a position x
    Scaled[s]scaled position s along the data
    {s,Above},{s,Below},relative position at position s along the data
    {pos,epos}epos in label placed at relative position pos of the data
  • ListPlot has the same options as Graphics, with the following additions and changes:
  • AspectRatio1/GoldenRatioratio of height to width
    AxesTruewhether to draw axes
    DataRangeAutomaticthe range of x values to assume for data
    FillingNonehow to fill in stems for each point
    FillingStyleAutomaticstyle to use for filling
    JoinedFalsewhether to join points
    LabelingFunctionAutomatichow to label points
    PerformanceGoal$PerformanceGoalaspects of performance to try to optimize
    PlotLabelNoneoverall label for the plot
    PlotLabelsNonelabels for data
    PlotLegendsNonelegends for data
    PlotMarkersNonemarkers to use to indicate each point
    PlotRangeAutomaticrange of values to include
    PlotRangeClippingTruewhether to clip at the plot range
    PlotStyleAutomaticgraphics directives to determine styles of points
    PlotTheme$PlotThemeoverall theme for the plot
    ScalingFunctionsNonehow to scale individual coordinates
    TargetUnitsAutomaticunits to display in the plot
  • DataRange determines how values {y1,,yn} are interpreted into {{x1,y1},,{xn,yn}}. Possible settings include:
  • Automatic,Alluniform from 1 to n
    {xmin,xmax}uniform from xmin to xmax
  • In general a list of pairs {{x1,y1},{x2,y2},} is interpreted as a list of points, but the setting DataRangeAll forces it to be interpreted as multiple datai {{y11,y12},{y21,y23},}.  »
  • LabelingFunction->f specifies that each point should have a label given by f[value,index,lbls], where value is the value associated with the point, index is its position in the data, and lbls is the list of relevant labels.
  • Typical settings for PlotLegends include:
  • Noneno legend
    Automaticautomatically determine legend
    {lbl1,lbl2,}use lbl1, lbl2, as legend labels
    Placed[lspec,]specify placement for legend
  • ScalingFunctions->"scale" scales the coordinate; ScalingFunctions{"scalex","scaley"} scales both and coordinates.

ExamplesExamplesopen allclose all

Basic Examples  (7)Basic Examples  (7)

Plot a list of values:

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

Plot a list of , pairs:

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

Plot several datai with a legend:

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

Label each point:

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

Label each datai:

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

Plot values including units:

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

Use individual colors for each point:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 1988
(1.0)
| Updated in 2016
(11.0)