# DiscretePlot

DiscretePlot[f,{n,nmax}]

generates a plot of f as a function of n when n=1,,nmax.

DiscretePlot[f,{n,nmin,nmax}]

generates a plot when n runs from nmin to nmax.

DiscretePlot[f,{n,nmin,nmax,dn}]

uses steps dn.

DiscretePlot[f,{n,{n1,,nm}}]

uses the successive values n1, , nm.

DiscretePlot[{f1,f2,},]

plots the values of all the fi.

# Details and Options

• DiscretePlot is typically used to visualize sequences.
• DiscretePlot uses the standard Wolfram Language iterator specification.
• DiscretePlot treats the variable n as local, effectively using Block.
• DiscretePlot has attribute HoldAll and evaluates f only after assigning specific numerical values to n.
• In some cases, it may be more efficient to use Evaluate to evaluate f symbolically before specific numerical values are assigned to n.
• The precision used in evaluating f is the minimum precision used in the iterator.
• The form w[f] provides a wrapper w to be applied to the resulting graphics primitives.
• The following wrappers can be used:
•  Annotation[f,label] provide an annotation Button[f,action] define an action to execute when the element is clicked Callout[f,label] label the element with a callout Callout[f,label,pos] place the callout at relative position pos EventHandler[f,…] define a general event handler for the element Hyperlink[f,uri] make the element act as a hyperlink Labeled[f,label] make the data a hyperlink Labeled[f,label,pos] place the label at relative position pos Legended[f,label] identify the element in a legend PopupWindow[f,cont] attach a popup window to the element StatusArea[f,label] display in the status area when the element is moused over Style[f,opts] show the element using the specified styles Tooltip[f,label] attach an arbitrary tooltip to the element
• Callout and Labeled can use the following positions pos:
•  Automatic automatically placed labels Above, Below, Before, After positions around the data x near the data at a position x {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
• Labels that depend on n will be applied for each plot element, while labels that are independent of n will only occur once.
• DiscretePlot has the same options as Graphics, with the following additions and changes: [List of all options]
•  AspectRatio 1/GoldenRatio ratio of height to width Axes True whether to draw axes ClippingStyle None what to draw when lines are clipped ColorFunction Automatic how to determine the coloring of lines ColorFunctionScaling True whether to scale arguments to ColorFunction EvaluationMonitor None expression to evaluate at every function evaluation ExtentElementFunction Automatic how to generate raw graphics for extent fills ExtentMarkers None markers to use for extent boundaries ExtentSize None width to extend from plot point Filling Axis filling from extent FillingStyle Automatic style to use for filling Joined Automatic whether to join points LabelingFunction Automatic how to label points LabelingSize Automatic maximum size of callouts and labels Method Automatic what method to use PerformanceGoal \$PerformanceGoal aspects of performance to try to optimize PlotLabels None labels for elements PlotLegends None legends for sequences PlotMarkers None markers to use for plot points PlotRange Automatic range of values to include PlotRangeClipping True whether to clip at the plot range PlotStyle Automatic graphics directives to determine the style of each line PlotTheme \$PlotTheme overall theme for the plot RegionFunction (True &) how to determine whether a point should be included ScalingFunctions None how to scale individual coordinates WorkingPrecision MachinePrecision precision for internal computation
• The arguments supplied to ColorFunction are , .
• With the setting ExtentSize->{sl,sr}, a horizontal line is drawn around each plot point, extending sl to the left and sr to the right. With ExtentMarkers->{ml,mr}, the markers ml and mr will be used as left and right extent boundary markers.
• With the default settings and , 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 ExtentElementFunction are the element region {{xmin,xmax},{ymin,ymax}} and the sample point {xi,yi}.
• With the setting , xmin is equal to xmax. With the setting , ymin is equal to ymax.
• Possible settings for ScalingFunctions include:
•  sy scale the y axis {sx,sy} scale x and y axes
• Each scaling function si is either a string "scale" or {g,g-1}, where g-1 is the inverse of g.
• ## List of all options

•  AlignmentPoint Center the default point in the graphic to align with AspectRatio 1/GoldenRatio ratio of height to width Axes True whether to draw axes AxesLabel None axes labels AxesOrigin Automatic where axes should cross AxesStyle {} style specifications for the axes Background None background color for the plot BaselinePosition Automatic how to align with a surrounding text baseline BaseStyle {} base style specifications for the graphic ClippingStyle None what to draw when lines are clipped ColorFunction Automatic how to determine the coloring of lines ColorFunctionScaling True whether to scale arguments to ColorFunction ContentSelectable Automatic whether to allow contents to be selected CoordinatesToolOptions Automatic detailed behavior of the coordinates tool Epilog {} primitives rendered after the main plot EvaluationMonitor None expression to evaluate at every function evaluation ExtentElementFunction Automatic how to generate raw graphics for extent fills ExtentMarkers None markers to use for extent boundaries ExtentSize None width to extend from plot point Filling Axis filling from extent FillingStyle Automatic style to use for filling FormatType TraditionalForm the default format type for text Frame False whether to put a frame around the plot FrameLabel None frame labels FrameStyle {} style specifications for the frame FrameTicks Automatic frame ticks FrameTicksStyle {} style specifications for frame ticks GridLines None grid lines to draw GridLinesStyle {} style specifications for grid lines ImageMargins 0. the margins to leave around the graphic ImagePadding All what extra padding to allow for labels etc. ImageSize Automatic the absolute size at which to render the graphic Joined Automatic whether to join points LabelingFunction Automatic how to label points LabelingSize Automatic maximum size of callouts and labels LabelStyle {} style specifications for labels Method Automatic what method to use PerformanceGoal \$PerformanceGoal aspects of performance to try to optimize PlotLabel None an overall label for the plot PlotLabels None labels for elements PlotLegends None legends for sequences PlotMarkers None markers to use for plot points PlotRange Automatic range of values to include PlotRangeClipping True whether to clip at the plot range PlotRangePadding Automatic how much to pad the range of values PlotRegion Automatic the final display region to be filled PlotStyle Automatic graphics directives to determine the style of each line PlotTheme \$PlotTheme overall theme for the plot PreserveImageOptions Automatic whether to preserve image options when displaying new versions of the same graphic Prolog {} primitives rendered before the main plot RegionFunction (True &) how to determine whether a point should be included RotateLabel True whether to rotate y labels on the frame ScalingFunctions None how to scale individual coordinates Ticks Automatic axes ticks TicksStyle {} style specifications for axes ticks WorkingPrecision MachinePrecision precision for internal computation

# Examples

open allclose all

## Basic Examples(4)

Plot a sequence:

Plot several sequences:

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

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

Use legends to identify functions:

## Scope(19)

### Data and Wrappers(4)

Plot multiple functions:

Use wrappers on functions or sets of functions:

Wrappers can be nested:

Override the default tooltips:

Use PopupWindow to provide additional drilldown information:

Button can be used to trigger any action:

Use ScalingFunctions to scale the axes:

### Labeling and Legending(8)

Label functions:

Label individual points:

Use callouts:

Apply callouts to extended regions:

Use Legended to provide a legend for a specific dataset:

Use Placed to change the legend location:

Use Callout to label datasets:

Use Callout to label elements:

Use Callout to label elements even when they are joined:

Specify a location for labels:

Specify label names with LabelingFunction:

### Styling and Appearance(7)

Use an explicit list of styles for the plots:

Style can be used to override styles:

Use any graphic for PlotMarkers:

Use any gradient or indexed color schemes from ColorData:

Use ExtentSize to associate a region with a point:

Show extent markers:

Use a theme with a frame and grid lines:

## Options(80)

### AspectRatio(4)

By default, DiscretePlot uses a fixed height to width ratio for the plot:

Make the height the same as the width with :

determines the ratio from the plot ranges:

adjusts the height and width to tightly fit inside other constructs:

### ColorFunction(6)

Color by scaled and coordinates, respectively:

Color joined plots:

Color filling element functions:

Color by height with a named color scheme:

Identify where jumps:

ColorFunction has higher priority than PlotStyle:

### ColorFunctionScaling(2)

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

Identify where jumps:

### EvaluationMonitor(1)

Gather the plotted heights:

Show the plot and a histogram of the heights:

### ExtentElementFunction(5)

Get a list of built-in settings for ExtentElementFunction:

For detailed settings, use Palettes Chart Element Schemes:

This ChartElementFunction is appropriate to show the global scale:

Write a custom ExtentElementFunction:

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

### ExtentMarkers(6)

Do not show the extent endpoints:

Use points to show the extent endpoints:

Show with appropriate continuity markers:

Show with appropriate continuity markers:

Control the size of markers:

Use custom shapes for the markers:

Markers use the settings for PlotStyle:

### ExtentSize(6)

Show heights as points:

Draw full regions around the heights:

With unevenly spaced points:

Use fixed-size regions:

With unevenly spaced points:

Use sizes relative to the distance between points:

With unevenly spaced points:

Use equally sized regions that do not overlap:

With unevenly spaced points:

Control the placement of the region around the points:

### Filling(6)

DiscretePlot automatically fills to the axis:

Turn off filling:

Use symbolic or explicit values:

With :

With :

Fill between curves 1 and 2:

Fill between curves 1 and 2 with a specific style:

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

### FillingStyle(4)

Use different fill colors:

Fill with opacity 0.5 orange:

Fill with red below the axis and blue above:

Use a variable filling style obtained from a ColorFunction:

### Joined(3)

Plots are automatically joined when there are many points:

Join the points:

Do not join the points:

### LabelingFunction(3)

Put labels above the points:

Put them in a tooltip:

Use callouts to label the points:

Label the points with their values:

### LabelingSize(1)

Specify a maximum size for textual labels:

Use the full label:

### PlotLabels(4)

Specify text to label sets of points:

Place the labels above the points:

Use callouts to identify the points:

Use None to not add a label:

### PlotLegends(6)

Generate a legend using labels:

Generate a legend using placeholders:

Use PlotLegends->"Expressions" to use the actual equations:

PlotLegends matches PlotStyle and PlotMarkers in the plot:

Use Placed to change legend position:

Use PointLegend to change legend appearance:

### PlotMarkers(8)

DiscretePlot normally uses distinct colors to distinguish different sets of data:

Automatically use colors and shapes to distinguish sets of data:

Markers are placed at the plot points regardless of the setting for ExtentSize:

Change the size of the default plot markers:

Use arbitrary text for plot markers:

Use explicit graphics for plot markers:

Use the same symbol for all the sets of data:

Explicitly use a symbol and size:

### PlotStyle(4)

Use different style directives:

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

Explicitly specify the style for different curves and regions:

PlotStyle can be combined with ColorFunction:

### PlotTheme(1)

Use a theme with a frame and grid lines:

Change the style for the grid lines:

### RegionFunction(1)

Draw over the region where :

### ScalingFunctions(7)

By default, plots have linear scales in each direction:

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

Use a log scale in the direction:

Reverse the axis without changing the axis:

Use different scales in the and directions:

Use a scale defined by a function and its inverse:

PlotRange and AxesOrigin are automatically scaled:

### WorkingPrecision(2)

Evaluate functions using machine-precision arithmetic:

Evaluate functions using arbitrary-precision arithmetic:

## Applications(4)

Plot the PDF of the empirical distribution of univariate data:

The CDF is a piecewise constant function:

Visualize the PDF and CDF for a discrete distribution:

Show Riemann sum approximations to the area under a curve:

Plot how many primes are below a number:

## Properties & Relations(4)

Plot generates continuous curves:

Use ListPlot to plot lists of values:

Use BarChart to show bars for lists of values:

Use DiscretePlot3D to plot functions of two discrete variables:

Wolfram Research (2008), DiscretePlot, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscretePlot.html (updated 2019).

#### Text

Wolfram Research (2008), DiscretePlot, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscretePlot.html (updated 2019).

#### CMS

Wolfram Language. 2008. "DiscretePlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/DiscretePlot.html.

#### APA

Wolfram Language. (2008). DiscretePlot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DiscretePlot.html

#### BibTeX

@misc{reference.wolfram_2023_discreteplot, author="Wolfram Research", title="{DiscretePlot}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/DiscretePlot.html}", note=[Accessed: 26-February-2024 ]}

#### BibLaTeX

@online{reference.wolfram_2023_discreteplot, organization={Wolfram Research}, title={DiscretePlot}, year={2019}, url={https://reference.wolfram.com/language/ref/DiscretePlot.html}, note=[Accessed: 26-February-2024 ]}