({{, (RefLink[DiscretePlot, paclet:ref/DiscretePlot])[expr,{n,(Subscript[n, max])}] 
generates a plot of the values of expr when n runs from 1 to (Subscript[n, max]).}, {, (RefLink[DiscretePlot, paclet:ref/DiscretePlot])[expr,{n,(Subscript[n, min]),(Subscript[n, max])}]
generates a plot of the values of expr when n runs from (Subscript[n, min]) to (Subscript[n, max]).}, {, (RefLink[DiscretePlot, paclet:ref/DiscretePlot])[expr,{n,(Subscript[n, min]),(Subscript[n, max]),dn}]
uses steps dn. }, {, (RefLink[DiscretePlot, paclet:ref/DiscretePlot])[expr,{n,{(Subscript[n, 1]),(Subscript[n, 2]),…}}]
uses the successive values (Subscript[n, 1]), (Subscript[n, 2]), ….}, {, (RefLink[DiscretePlot, paclet:ref/DiscretePlot])[{(Subscript[expr, 1]),(Subscript[expr, 2]),…},…]
plots the values of all the (Subscript[expr, i]).}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[DiscretePlot, paclet:ref/DiscretePlot]) uses the standard Wolfram Language iterator specification.

(RefLink[DiscretePlot, paclet:ref/DiscretePlot]) treats the variable n as local, effectively using (RefLink[Block, paclet:ref/Block]).

(RefLink[DiscretePlot, paclet:ref/DiscretePlot]) has attribute (RefLink[HoldAll, paclet:ref/HoldAll]) and evaluates expr only after assigning specific numerical values to n.

In some cases, it may be more efficient to use (RefLink[Evaluate, paclet:ref/Evaluate]) to evaluate expr symbolically before specific numerical values are assigned to n.

The precision used in evaluating expr is the minimum precision used in the iterator.

The form w[expr] provides a wrapper w to be applied to the resulting graphics primitives.

The following wrappers can be used:

(RefLink[Callout, paclet:ref/Callout]) and (RefLink[Labeled, paclet:ref/Labeled]) can use the following positions pos:

Labels that depend on n will be applied for each plot element, while labels that are independent of n will only occur once.

(RefLink[DiscretePlot, paclet:ref/DiscretePlot]) has the same options as (RefLink[Graphics, paclet:ref/Graphics]), with the following additions and changes:

The arguments supplied to (RefLink[ColorFunction, paclet:ref/ColorFunction]) are x, y.

With the setting (RefLink[ExtentSize, paclet:ref/ExtentSize])->{(Subscript[s, l]),(Subscript[s, r])}, a horizontal line is drawn around each plot point, extending (Subscript[s, l]) to the left and (Subscript[s, r]) to the right. With (RefLink[ExtentMarkers, paclet:ref/ExtentMarkers])->{(Subscript[m, l]),(Subscript[m, r])}, the markers (Subscript[m, l]) and (Subscript[m, r]) will be used as left and right extent boundary markers.

With the default settings (RefLink[Joined, paclet:ref/Joined])->(RefLink[Automatic, paclet:ref/Automatic]) and (RefLink[Filling, paclet:ref/Filling])->(RefLink[Axis, paclet:ref/Axis]), (RefLink[DiscretePlot, paclet:ref/DiscretePlot]) switches between drawing points with a stem filling when there are few points and lines with a solid filling when there are many points.

The arguments supplied to (RefLink[ExtentElementFunction, paclet:ref/ExtentElementFunction]) are the element region {{(Subscript[x, min]),(Subscript[x, max])},{(Subscript[y, min]),(Subscript[y, max])}} and the sample point {(Subscript[x, i]),(Subscript[y, i])}.

With the setting (RefLink[ExtentSize, paclet:ref/ExtentSize])->(RefLink[None, paclet:ref/None]), (Subscript[x, min]) is equal to (Subscript[x, max]). With the setting (RefLink[Filling, paclet:ref/Filling])->(RefLink[None, paclet:ref/None]), (Subscript[y, min]) is equal to (Subscript[y, max]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (110)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Plot a sequence:

DiscretePlot[PrimePi[k],{k,1,50}]

DiscretePlot[MoebiusMu[k],{k,1,50}]

Plot several sequences:

Table[PDF[BinomialDistribution[50,p],k],{p,{0.3,0.5,0.8}}];

DiscretePlot[Evaluate[%],{k,1,50}]

Show a Riemann sum approximation to the area under a curve:

Show[DiscretePlot[Sin[t],{t,0,2Pi,Pi/6},ExtentSize->Full],Plot[Sin[t],{t,0,2Pi}]]

With bars to the left and right of the sample points:

Table[DiscretePlot[Sin[t],{t,0,2Pi,Pi/6},ExtentSize->a,PlotMarkers->"Point",AxesOrigin->{0,0}],{a,{Left,Right}}]

Use legends to identify functions:

data=Table[PDF[BinomialDistribution[50,p],k],{p,{0.3,0.5,0.8}}];

DiscretePlot[Evaluate@data,{k,1,50},PlotLegends->{0.3,0.5,0.8}]

OpenersExampleSection1(Spacer1)Scope  (19)

OpenersExampleSubsection0(Spacer1)Data and Wrappers  (4)

Plot multiple functions:

DiscretePlot[{Sin[t],Cos[t],Sin[Pi+t]},{t,0,2Pi,Pi/12}]

Use wrappers on functions or sets of functions:

{DiscretePlot[{Sin[t],Style[Cos[t],Red],Sin[Pi+t]},{t,0,2*Pi, Pi/12}],DiscretePlot[Style[{Sin[t],Cos[t],Sin[Pi+t]},Red],{t,0,2*Pi, Pi/12}]}

Wrappers can be nested:

DiscretePlot[Style[{Sin[t],Style[Cos[t],Blue],Sin[Pi+t]},Red],{t,0,2*Pi, Pi/12}]

Override the default tooltips:

DiscretePlot[{Sin[t],Tooltip[Cos[t],"my data"],Sin[Pi+t]},{t,0,2*Pi, Pi/12}]

Use (RefLink[PopupWindow, paclet:ref/PopupWindow]) to provide additional drilldown information:

DiscretePlot[Evaluate@Table[PopupWindow[PDF[
      PoissonDistribution[λ], t],SmoothHistogram[Tooltip[RandomVariate[PoissonDistribution[λ],100],λ],Filling->Bottom]],{λ,{10,20,30}}], 
  {t, 0, 30},PlotRange->All]

(RefLink[Button, paclet:ref/Button]) can be used to trigger any action:

DiscretePlot[Evaluate@Table[With[{lambda=λ},Button[PDF[
      PoissonDistribution[lambda], t], 
  Speak[PoissonDistribution[lambda]]]],{λ,{10,20,30}}], 
  {t, 0, 30},PlotRange->All]

Use (RefLink[ScalingFunctions, paclet:ref/ScalingFunctions]) to scale the axes:

DiscretePlot[LCM[x],{x,1,100,5},ExtentSize->Full,ScalingFunctions->"Log"]

OpenersExampleSubsection1(Spacer1)Labeling and Legending  (8)

Label functions:

DiscretePlot[{Labeled[Prime[n],"primes"],Labeled[n Log[n],"estimate"]},{n,250}]

Label individual points:

DiscretePlot[Labeled[Prime[t],Prime[t]],{t,20}]

Use callouts:

DiscretePlot[Callout[Prime[t],Prime[t]],{t,20}]

Apply callouts to extended regions:

DiscretePlot[Callout[Prime[t],Prime[t]],{t,20},ExtentSize->Full]

Use (RefLink[Legended, paclet:ref/Legended]) to provide a legend for a specific dataset:

upper=Prime[n];
lower=n Log[n];

DiscretePlot[{lower,Legended[Mean[{lower,upper}],"average"],upper}, {n,1,200}]

Use (RefLink[Placed, paclet:ref/Placed]) to change the legend location:

DiscretePlot[{lower,Legended[Mean[{lower,upper}],Placed["average",Below]],upper},{n,1,200}]

Use (RefLink[Callout, paclet:ref/Callout]) to label datasets:

DiscretePlot[{Callout[lower,"label", Automatic],Callout[upper,"label",Automatic]},{n,1,100},ExtentSize->Full]

Use (RefLink[Callout, paclet:ref/Callout]) to label elements:

DiscretePlot[{Callout[n Log[n],Round[n Log[n],0.1]],Callout[Prime[n],Prime[n]]},{n,1,10},ExtentSize->Full]

Use (RefLink[Callout, paclet:ref/Callout]) to label elements even when they are joined:

DiscretePlot[{Callout[n Log[n],Round[n Log[n],0.1]],Callout[Prime[n],Prime[n]]},{n,1,10},Joined->True]

Specify a location for labels:

DiscretePlot[Prime[t],{t,1,20},LabelingFunction->Above]

Specify label names with (RefLink[LabelingFunction, paclet:ref/LabelingFunction]):

DiscretePlot[Prime[t],{t,1,20},LabelingFunction->(#1 &)]

OpenersExampleSubsection2(Spacer1)Styling and Appearance  (7)

Use an explicit list of styles for the plots:

DiscretePlot[{Sin[t],Cos[t],Sin[Pi+t]},{t,0,2*Pi,Pi/12},PlotStyle->{Red,Green,Blue}]

(RefLink[Style, paclet:ref/Style]) can be used to override styles:

DiscretePlot[{Sin[t],Style[Cos[t],Red],Sin[Pi+t]},{t,0,2*Pi,Pi/12},PlotStyle->Gray]

Use any graphic for (RefLink[PlotMarkers, paclet:ref/PlotMarkers]):

DiscretePlot[PDF[BinomialDistribution[10,.5],t],{t,0,10},PlotMarkers->{{Graphics3D[Sphere[],Boxed->False],0.15}}]

Use any gradient or indexed color schemes from (RefLink[ColorData, paclet:ref/ColorData]):

DiscretePlot[{Sin[t],Cos[t],Sin[Pi+t]},{t,0,2*Pi,Pi/12},ColorFunction->Function[{x,y},ColorData["NeonColors"][y]]]

Use (RefLink[ExtentSize, paclet:ref/ExtentSize]) to associate a region with a point:

Table[DiscretePlot[PDF[BinomialDistribution[10,.5],t],{t,0,10},ExtentSize->s,PlotMarkers->Point,PlotLabel->s],{s,{Left,Full,Right,Scaled[0.5]}}]

Show extent markers:

DiscretePlot[PDF[BinomialDistribution[10,.5],t],{t,0,10},ExtentSize->Full,ExtentMarkers->{"Filled","Empty"},ColorFunction->"Rainbow"]

Use a theme with a frame and grid lines:

DiscretePlot[PDF[BinomialDistribution[10,.5],t],{t,0,10},PlotTheme->"Detailed"]

OpenersExampleSection2(Spacer1)Options  (79)

OpenersExampleSubsection3(Spacer1)AxesLabel  (2)

Use labels based on variables specified in (RefLink[DiscretePlot, paclet:ref/DiscretePlot]):

DiscretePlot[PDF[PoissonDistribution[5],x],{x,0,10},AxesLabel->Automatic]

Specify a label for each axis:

DiscretePlot[PDF[PoissonDistribution[5],x],{x,0,10},AxesLabel->{"x",PDF[PoissonDistribution[5],x]}]

OpenersExampleSubsection4(Spacer1)ColorFunction  (6)

Color by scaled x and y coordinates, respectively:

Table[DiscretePlot[GCD[n,60],{n,59},Evaluate[ColorFunction->f]],{f,{Function[{x,y},Hue[0.8x]],Function[{x,y},Hue[0.8y]]}}]

Color joined plots:

Table[DiscretePlot[GCD[n,60],{n,59},Joined->True,Evaluate[ColorFunction->f]],{f,{Function[{x,y},Hue[0.8x]],Function[{x,y},Hue[0.8y]]}}]

Color filling element functions:

Table[DiscretePlot[GCD[n,24],{n,23},ExtentSize->Full,Evaluate[ColorFunction->f]],{f,{Function[{x,y},Hue[0.8x]],Function[{x,y},Hue[0.8y]]}}]

Color by height with a named color scheme:

DiscretePlot[GCD[n,24],{n,23},ExtentSize->Full,ColorFunction->"Rainbow"]

Identify where (PrimePi[n]) jumps:

DiscretePlot[PrimePi[n],{n,2,25},ExtentSize->Full,ColorFunction->Function[{x,y},If[x==Prime[Round[y]],Red,Blue]],ColorFunctionScaling->False]

(RefLink[ColorFunction, paclet:ref/ColorFunction]) has higher priority than (RefLink[PlotStyle, paclet:ref/PlotStyle]):

DiscretePlot[GCD[n,60],{n,59},ColorFunction->"Rainbow",PlotStyle->Directive[Red,PointSize[Large]]]

OpenersExampleSubsection5(Spacer1)ColorFunctionScaling  (2)

No argument scaling on the left; automatic scaling on the right:

Table[DiscretePlot[PDF[PoissonDistribution[12],x],{x,0,50},ColorFunction->Hue,ColorFunctionScaling->cf],{cf,{True,False}}]

Identify where (PrimePi[n]) jumps:

DiscretePlot[PrimePi[n],{n,2,25},ExtentSize->Full,ColorFunction->Function[{x,y},If[x==Prime[Round[y]],Red,Blue]],ColorFunctionScaling->False]

OpenersExampleSubsection6(Spacer1)EvaluationMonitor  (1)

Gather the plotted heights:

{plot,points}=Reap[DiscretePlot[Mod[Prime[n],n],{n,200},Joined->False,EvaluationMonitor:>Sow[Mod[Prime[n],n]]]];

Show the plot and a histogram of the heights:

{plot, Histogram[points,{10}]}

OpenersExampleSubsection7(Spacer1)ExtentElementFunction  (5)

Get a list of built-in settings for (RefLink[ExtentElementFunction, paclet:ref/ExtentElementFunction]):

ChartElementData["DiscretePlot"]

For detailed settings, use Palettes ▶ Chart Element Schemes:

Table[DiscretePlot[PDF[PoissonDistribution[12],n],{n,25},ExtentSize->Full,ExtentElementFunction->f],{f,{"ArrowRectangle","ObliqueRectangle"}}]

Table[DiscretePlot[PDF[PoissonDistribution[12],n],{n,25},ExtentSize->Full,ExtentElementFunction->f],{f,{"FadingRectangle","GlassRectangle"}}]

This (RefLink[ChartElementFunction, paclet:ref/ChartElementFunction]) is appropriate to show the global scale:

Table[DiscretePlot[PDF[PoissonDistribution[12],n],{n,25},ExtentSize->Full,ExtentElementFunction->f],{f,{"GradientScaleRectangle","SegmentScaleRectangle"}}]

Write a custom (RefLink[ExtentElementFunction, paclet:ref/ExtentElementFunction]):

f[{{xmin_,xmax_},{ymin_,ymax_}},___]:={AbsoluteThickness[3],CapForm["Butt"],Line[{{xmin,ymin},{xmax,ymax}}],AbsoluteDashing[{9}],AbsoluteThickness[2.5],CapForm["Butt"],White,Line[{{xmin,ymin},{xmax,ymax}}]}

DiscretePlot[PDF[PoissonDistribution[12],n],{n,25},ExtentElementFunction->f]

g[{{xmin_,xmax_},{ymin_,ymax_}},___]:=Rectangle[{xmin,ymin},{xmax,ymax},RoundingRadius->Offset[5]]

DiscretePlot[PDF[PoissonDistribution[12],n],{n,25},ExtentSize->Full,ExtentElementFunction->g]

Built-in element functions may have options; use Palettes ▶ Chart Element Schemes to set them:

ChartElementData["GradientRectangle","Options"]

Table[DiscretePlot[PDF[PoissonDistribution[12],n],{n,25},ExtentSize->Full,ExtentElementFunction->ChartElementData["GradientRectangle","ColorScheme"->"DeepSeaColors","GradientOrigin"->dir]],{dir,{Left,Right,Top,Bottom}}]

OpenersExampleSubsection8(Spacer1)ExtentMarkers  (6)

Do not show the extent endpoints:

DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->Full,ExtentMarkers->None]

Use points to show the extent endpoints:

DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->Full,ExtentMarkers->"Point"]

Show (Floor[n]) with appropriate continuity markers:

DiscretePlot[Floor[n],{n,0,10},ExtentSize->Right,ExtentMarkers->{"Filled","Empty"}]

Show (Ceiling[n]) with appropriate continuity markers:

DiscretePlot[Ceiling[n],{n,0,10},ExtentSize->Left,ExtentMarkers->{"Empty","Filled"}]

Control the size of markers:

Table[DiscretePlot[Floor[n],{n,10},ExtentSize->Right,ExtentMarkers->{{"Filled",size},{"Empty",size}}],{size,{Tiny,Small,Medium}}]

Use custom shapes for the markers:

DiscretePlot[Ceiling[n],{n,10},ExtentSize->Left,ExtentMarkers->{{Graphics3D[Sphere[],Boxed->False],0.15},None}]

Markers use the settings for (RefLink[PlotStyle, paclet:ref/PlotStyle]):

DiscretePlot[Ceiling[n],{n,10},ExtentSize->{Full,None},ExtentMarkers->{"Filled","Empty"},PlotStyle->Orange]

OpenersExampleSubsection9(Spacer1)ExtentSize  (6)

Show heights as points:

DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->None]

Draw full regions around the heights:

DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->Full]

With unevenly spaced points:

DiscretePlot[GCD[m,24],{m,{1,2,3,5,8,13}},ExtentSize->Full]

Use fixed-size regions:

DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->0.5]

With unevenly spaced points:

DiscretePlot[GCD[m,24],{m,{1,2,3,5,8,13}},ExtentSize->0.5]

Use sizes relative to the distance between points:

DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->Scaled[0.75]]

With unevenly spaced points:

DiscretePlot[GCD[m,24],{m,{1,2,3,5,8,13}},ExtentSize->Scaled[0.75]]

Use equally sized regions that do not overlap:

DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->All]

With unevenly spaced points:

DiscretePlot[GCD[m,24],{m,{1,2,3,5,8,13}},ExtentSize->All]

Control the placement of the region around the points:

Table[DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->es,PlotLabel->es,PlotMarkers->"Point"],{es,{{None,Full},{Full,None}}}]

OpenersExampleSubsection10(Spacer1)Filling  (6)

(RefLink[DiscretePlot, paclet:ref/DiscretePlot]) automatically fills to the axis:

Table[DiscretePlot[PrimePi[n],{n,25},Evaluate[opt]],{opt,{Joined->False,Joined->True,ExtentSize->Full}}]

Turn off filling:

Table[DiscretePlot[PrimePi[n],{n,25},Filling->None,Evaluate[opt]],{opt,{Joined->False,Joined->True,ExtentSize->Full}}]

Use symbolic or explicit values:

Table[DiscretePlot[PrimePi[n],{n,25},Filling->f,PlotLabel->f],{f,{Axis,Top,Bottom,5}}]

With (RefLink[Joined, paclet:ref/Joined])->(RefLink[True, paclet:ref/True]):

Table[DiscretePlot[PrimePi[n],{n,25},Filling->f,PlotLabel->f,Joined->True],{f,{Axis,Top,Bottom,5}}]

With (RefLink[ExtentSize, paclet:ref/ExtentSize])->(RefLink[Full, paclet:ref/Full]):

Table[DiscretePlot[PrimePi[n],{n,25},Filling->f,PlotLabel->f,ExtentSize->Full],{f,{Axis,Top,Bottom,5}}]

Fill between curves 1 and 2:

Table[DiscretePlot[{PrimePi[n],n/Log[n]},{n,2,25},Filling->{1->{2}},Evaluate[opt]],{opt,{Joined->False,Joined->True,ExtentSize->Full}}]

Fill between curves 1 and 2 with a specific style:

Table[DiscretePlot[{PrimePi[n],n/Log[n]},{n,2,25},Filling->{1->{{2},Gray}},Evaluate[opt]],{opt,{Joined->False,Joined->True,ExtentSize->Full}}]

Fill between curves 1 and 2; use red when 1 is below 2 and blue when 1 is above 2:

Table[DiscretePlot[{PrimePi[n],n/Log[n]},{n,2,25},Filling->{1->{{2},{Red,Blue}}},Evaluate[opt]],{opt,{Joined->False,Joined->True,ExtentSize->Full}}]

OpenersExampleSubsection11(Spacer1)FillingStyle  (4)

Use different fill colors:

Table[DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},FillingStyle->c],{c,{Red,Green,Blue,Yellow}}]

Fill with opacity 0.5 orange:

DiscretePlot[Evaluate[Table[PDF[PoissonDistribution[k],x],{k,{8,12,16}}]],{x,25},ExtentSize->Full,FillingStyle->Directive[Opacity[0.5],Orange]]

Fill with red below the x axis and blue above:

Table[DiscretePlot[Sin[x],{x,0,2Pi,Pi/8},FillingStyle->{Red,Blue},ExtentSize->e],{e,{None,Full}}]

Use a variable filling style obtained from a (RefLink[ColorFunction, paclet:ref/ColorFunction]):

Table[DiscretePlot[Sin[x],{x,0,2Pi,Pi/8},ColorFunction->Function[{x,y},Hue[y]],FillingStyle->Automatic,ExtentSize->e],{e,{None,Full}}]

OpenersExampleSubsection12(Spacer1)Joined  (3)

Plots are automatically joined when there are many points:

{DiscretePlot[PrimePi[n],{n,50}],DiscretePlot[PrimePi[n],{n,500}]}

Join the points:

DiscretePlot[PrimePi[n],{n,50},Joined->True]

Do not join the points:

DiscretePlot[PrimePi[n],{n,500},Joined->False]

OpenersExampleSubsection13(Spacer1)LabelingFunction  (3)

Put labels above the points:

DiscretePlot[Prime[t],{t,1,10},LabelingFunction->Above]

Put them in a tooltip:

DiscretePlot[Prime[t],{t,1,10},LabelingFunction->Tooltip]

Use callouts to label the points:

DiscretePlot[Prime[t],{t,1,10},LabelingFunction->Callout[Automatic,Automatic]]

Label the points with their values:

DiscretePlot[Prime[t],{t,1,10},LabelingFunction->(#1&)]

OpenersExampleSubsection14(Spacer1)LabelingSize  (1)

Specify a maximum size for textual labels:

DiscretePlot[Labeled[Prime[n],IntegerName[n]],{n,1,20},ImageSize->Medium,LabelingSize->30]

Use the full label:

DiscretePlot[Labeled[Prime[n],IntegerName[n]],{n,1,20},ImageSize->Medium,LabelingSize->Full]

OpenersExampleSubsection15(Spacer1)PlotLabels  (4)

Specify text to label sets of points:

DiscretePlot[{Sin[t],Cos[t]},{t,0,2 Pi, 0.1},PlotLabels->{"sine","cosine"}]

Place the labels above the points:

DiscretePlot[{Sin[t],Cos[t]},{t,0,2 Pi, 0.1},PlotLabels->Placed[{"sine","cosine"},Above]]

Use callouts to identify the points:

DiscretePlot[{Sin[t],Cos[t]},{t,0,2 Pi, 0.1},PlotLabels->{Callout["sin",{Scaled[0.25],Above}],Callout["cos",{Scaled[0.5],Below}]}]

Use (RefLink[None, paclet:ref/None]) to not add a label:

DiscretePlot[{Sin[t],Cos[t]},{t,0,2 Pi, 0.1},PlotLabels->{"sine",None}]

OpenersExampleSubsection16(Spacer1)PlotLegends  (6)

Generate a legend using labels:

DiscretePlot[{Log[x],Sqrt[x]},{x,0,2,0.1},PlotLegends->{"log","sqrt"}]

Generate a legend using placeholders:

DiscretePlot[{Sin[x],Cos[x]},{x,0,2π,π/10},PlotLegends->Automatic]

Use (RefLink[PlotLegends, paclet:ref/PlotLegends])->"Expressions" to use the actual equations:

DiscretePlot[{Sin[x],Cos[x]},{x,0,2π,π/10},PlotLegends->"Expressions"]

(RefLink[PlotLegends, paclet:ref/PlotLegends]) matches (RefLink[PlotStyle, paclet:ref/PlotStyle]) and (RefLink[PlotMarkers, paclet:ref/PlotMarkers]) in the plot:

DiscretePlot[{Sin[x],Sin[2 x]},{x,0,2π,0.25},PlotStyle->{Blue,Red},PlotLegends->PointLegend["Expressions",LegendMarkers->Automatic],PlotMarkers->Automatic]

Use (RefLink[Placed, paclet:ref/Placed]) to change legend position:

Table[DiscretePlot[{Sin[x^2],Sin[x]},{x,0,π,0.1},PlotLegends->Placed["Expressions",pos]],{pos,{Above,Below}}]

Use (RefLink[PointLegend, paclet:ref/PointLegend]) to change legend appearance:

DiscretePlot[{Sin[x],Cos[x]},{x,0,10,0.2},PlotLegends->PointLegend["Expressions",LegendFunction->Panel,LegendLabel->"label"]]

OpenersExampleSubsection17(Spacer1)PlotMarkers  (8)

(RefLink[DiscretePlot, paclet:ref/DiscretePlot]) normally uses distinct colors to distinguish different sets of data:

Table[DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},Evaluate[opt]],{opt,{Joined->False,Joined->True,ExtentSize->Full}}]

Automatically use colors and shapes to distinguish sets of data:

Table[DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},PlotMarkers->Automatic,Evaluate[opt]],{opt,{Joined->False,Joined->True,ExtentSize->Full}}]

Markers are placed at the plot points regardless of the setting for (RefLink[ExtentSize, paclet:ref/ExtentSize]):

Table[DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},PlotMarkers->Automatic,ExtentSize->es],{es,{None,Left,Right,Full}}]

Change the size of the default plot markers:

Table[DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},PlotMarkers->{Automatic,s}],{s,{Tiny,Small,Medium,Large}}]

Use arbitrary text for plot markers:

DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},PlotMarkers->{"1","2","3"}]

Use explicit graphics for plot markers:

DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},PlotMarkers->Table[{s,0.05},{s,{,,}}]]

Use the same symbol for all the sets of data:

DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},PlotMarkers->"●"]

Explicitly use a symbol and size:

Table[DiscretePlot[{n,(Sqrt[n]),(n^(1/3))},{n,10},PlotMarkers->{"●",s}],{s,{4,8,12}}]

OpenersExampleSubsection18(Spacer1)PlotStyle  (4)

Use different style directives:

Table[DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},PlotStyle->ps],{ps,{Orange,Thick,Dotted,Directive[Orange,Thick]}}]

Table[DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},ExtentSize->Full,PlotStyle->ps],{ps,{Orange,Thick,Dotted,Directive[Orange,Thick]}}]

Table[DiscretePlot[PDF[PoissonDistribution[12],x],{x,25},Joined->True,PlotStyle->ps],{ps,{Orange,Thick,Dotted,Directive[Orange,Thick]}}]

By default, different styles are chosen for multiple curves and regions:

Table[DiscretePlot[Evaluate[Table[PDF[PoissonDistribution[k],x],{k,{8,12,16}}]],{x,25},Evaluate[opt]],{opt,{Joined->False,ExtentSize->Full,Joined->True}}]

Explicitly specify the style for different curves and regions:

Table[DiscretePlot[Evaluate[Table[PDF[PoissonDistribution[k],x],{k,{8,12,16}}]],{x,25},Evaluate[opt],PlotStyle->{Red,Blue,Orange}],{opt,{Joined->False,ExtentSize->Full,Joined->True}}]

(RefLink[PlotStyle, paclet:ref/PlotStyle]) can be combined with (RefLink[ColorFunction, paclet:ref/ColorFunction]):

Table[DiscretePlot[PDF[PoissonDistribution[16],x],{x,25},Evaluate[opt],PlotStyle->Thick,ColorFunction->"Rainbow"],{opt,{Joined->False,ExtentSize->Full,Joined->True}}]

OpenersExampleSubsection19(Spacer1)PlotTheme  (1)

Use a theme with a frame and grid lines:

DiscretePlot[{n Log[n],Prime[n]},{n,1,100},PlotTheme->"Detailed"]

Change the style for the grid lines:

DiscretePlot[{n Log[n],Prime[n]},{n,1,100},PlotTheme->"Detailed",GridLinesStyle->LightGray]

OpenersExampleSubsection20(Spacer1)RegionFunction  (1)

Draw over the region where x≤y:

Table[DiscretePlot[x+Sin[x],{x,35},Evaluate[opt],RegionFunction->Function[{x,y},x≤y]],{opt,{Joined->False,ExtentSize->Full,Joined->True}}]

OpenersExampleSubsection21(Spacer1)ScalingFunctions  (8)

By default, plots have linear scales in each direction:

DiscretePlot[PrimePi[k],{k,1,50}]

Use a linear scale in the y direction that shows smaller numbers at the top:

DiscretePlot[PrimePi[k],{k,1,50},ScalingFunctions->"Reverse"]

Use a log scale in the x direction:

DiscretePlot[PrimePi[k],{k,1,50},ScalingFunctions->{"Log", None}]

Reverse the x axis without changing the y axis:

DiscretePlot[PrimePi[k],{k,1,50},ScalingFunctions->{"Reverse",None}]

Use different scales in the x and y directions:

DiscretePlot[PrimePi[k],{k,1,50},ScalingFunctions->{"Reverse","Log"}]

Use a scale defined by a function and its inverse:

DiscretePlot[PrimePi[k],{k,1,50},ScalingFunctions->{None,{-Log[#]&,Exp[-#]&}}]

Positions in (RefLink[Ticks, paclet:ref/Ticks]) and (RefLink[GridLines, paclet:ref/GridLines]) are automatically scaled:

DiscretePlot[PrimePi[k],{k,1,50},Ticks->{Automatic,2^Range[10]},GridLines->{None,2^Range[10]}]

(RefLink[PlotRange, paclet:ref/PlotRange]) and (RefLink[AxesOrigin, paclet:ref/AxesOrigin]) are automatically scaled:

DiscretePlot[PrimePi[k],{k,1,50},ScalingFunctions->"Log",PlotRange->{1,100},AxesOrigin->{Automatic,10}]

OpenersExampleSubsection22(Spacer1)WorkingPrecision  (2)

Evaluate functions using machine-precision arithmetic:

DiscretePlot[CoshIntegral[j]-Log[j]+SinhIntegral[j],{j,-50,-1},AxesOrigin->{0,0}]

Evaluate functions using arbitrary-precision arithmetic:

DiscretePlot[CoshIntegral[j]-Log[j]+SinhIntegral[j],{j,-50,-1},AxesOrigin->{0,0},WorkingPrecision->30]

OpenersExampleSection3(Spacer1)Applications  (4)

Plot the PDF of the empirical distribution of univariate data:

data=RandomVariate[NormalDistribution[],15];

dist=EmpiricalDistribution[data]

DiscretePlot[PDF[dist,x],{x,DistributionDomain[dist]}]

The CDF is a piecewise constant function:

DiscretePlot[CDF[dist,x],{x,DistributionDomain[dist]},ExtentSize->Left]

Visualize the PDF and CDF for a discrete distribution:

Show[DiscretePlot[PDF[BenfordDistribution[10],x],{x,1,13},PlotMarkers->{"Point",Large}],DiscretePlot[CDF[BenfordDistribution[10],x],{x,1,13},ExtentSize->Right,Filling->0],PlotRange->All]

Show Riemann sum approximations to the area under a curve:

plot=Plot[Sin[x],{x,0,2Pi},PlotStyle->Thick];

Table[Show[plot,DiscretePlot[Sin[x],{x,0,2Pi,Pi/8},ExtentSize->s,PlotLabel->s]],{s,{Full,Left,Right}}]

Plot how many primes are below a number:

DiscretePlot[PrimePi[p],{p,Prime[Range[20]]},ExtentSize->Right,PlotMarkers->Point,AxesOrigin->{0,0}]

OpenersExampleSection4(Spacer1)Properties & Relations  (4)

(RefLink[Plot, paclet:ref/Plot]) generates continuous curves:

{Plot[PrimePi[x],{x,0,15}],DiscretePlot[PrimePi[x],{x,0,15}]}

Use (RefLink[ListPlot, paclet:ref/ListPlot]) to plot lists of values:

{ListPlot[{1,2,3,4,5,6,7,8,9,10}],DiscretePlot[x,{x,10}]}

Use (RefLink[BarChart, paclet:ref/BarChart]) to show bars for lists of values:

{BarChart[Range[10]],DiscretePlot[x,{x,10},ExtentSize->Full]}

Use (RefLink[DiscretePlot3D, paclet:ref/DiscretePlot3D]) to plot functions of two discrete variables:

DiscretePlot3D[PDF[MultivariatePoissonDistribution[4,{1,2}],{x,y}],{x,0,10},{y,0,10},ExtentSize->Scaled[0.5]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ListPlot, paclet:ref/ListPlot])  ▪  (RefLink[ListLinePlot, paclet:ref/ListLinePlot])  ▪  (RefLink[ListLogPlot, paclet:ref/ListLogPlot])  ▪  (RefLink[DateListPlot, paclet:ref/DateListPlot])  ▪  (RefLink[ListStepPlot, paclet:ref/ListStepPlot])  ▪  (RefLink[Plot, paclet:ref/Plot])  ▪  (RefLink[Table, paclet:ref/Table])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Function Visualization, paclet:guide/FunctionVisualization])}, {▪(RefLinkPlain[Discrete Calculus, paclet:guide/DiscreteCalculus])}, {▪(RefLinkPlain[Data Visualization, paclet:guide/DataVisualization])}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}, {▪(RefLinkPlain[Nonparametric Statistical Distributions, paclet:guide/NonparametricStatisticalDistributions])}, {▪(RefLinkPlain[Statistical Visualization, paclet:guide/StatisticalVisualization])}})}})