({{, (RefLink[Plot, paclet:ref/Plot])[f,{x,(Subscript[x, min]),(Subscript[x, max])}]
generates a plot of f as a function of x from (Subscript[x, min]) to (Subscript[x, max]). }, {, (RefLink[Plot, paclet:ref/Plot])[{(Subscript[f, 1]),(Subscript[f, 2]),…},{x,(Subscript[x, min]),(Subscript[x, max])}]
plots several functions (Subscript[f, i]). }, {, (RefLink[Plot, paclet:ref/Plot])[{…,w[(Subscript[f, i])],…},…]
plots (Subscript[f, i]) with features defined by the symbolic wrapper w.}, {, (RefLink[Plot, paclet:ref/Plot])[…,{x}∈reg]
takes the variable x to be in the geometric region reg.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[Plot, paclet:ref/Plot]) evaluates f at different values of x to create a smooth curve of the form {x,f[x]}.

Gaps are left at any x where the (Subscript[f, i]) evaluate to anything other than real numbers or (RefLink[Quantity, paclet:ref/Quantity]).

The limits (Subscript[x, min]) and (Subscript[x, max]) can be real numbers or (RefLink[Quantity, paclet:ref/Quantity]) expressions.

The region reg can be any (RefLink[RegionQ, paclet:ref/RegionQ]) object in 1D.

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

(RefLink[Plot, paclet:ref/Plot]) has attribute (RefLink[HoldAll, paclet:ref/HoldAll]) and evaluates f only after assigning specific numerical values to x.

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

The following wrappers w can be used for the (Subscript[f, i]):

Wrappers w can be applied at multiple levels:

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

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

Possible settings for (RefLink[ClippingStyle, paclet:ref/ClippingStyle]) are:

With the default settings (RefLink[Exclusions, paclet:ref/Exclusions])->(RefLink[Automatic, paclet:ref/Automatic]) and (RefLink[ExclusionsStyle, paclet:ref/ExclusionsStyle])->(RefLink[None, paclet:ref/None]), (RefLink[Plot, paclet:ref/Plot]) breaks curves at discontinuities and singularities it detects. (RefLink[Exclusions, paclet:ref/Exclusions])->(RefLink[None, paclet:ref/None]) joins across discontinuities and singularities.

(RefLink[Exclusions, paclet:ref/Exclusions])->{(Subscript[x, 1]),(Subscript[x, 2]),…} is equivalent to (RefLink[Exclusions, paclet:ref/Exclusions])->{x==(Subscript[x, 1]),x==(Subscript[x, 2]),…}.

(RefLink[PlotLegends, paclet:ref/PlotLegends])->"Expressions" uses the (Subscript[f, i]) as the legend text.

(RefLink[Plot, paclet:ref/Plot]) initially evaluates f at a number of equally spaced sample points specified by (RefLink[PlotPoints, paclet:ref/PlotPoints]). Then it uses an adaptive algorithm to choose additional sample points, subdividing a given interval at most (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) times.

Since only a finite number of sample points are used, it is possible for (RefLink[Plot, paclet:ref/Plot]) to miss features of f. Increasing the settings for (RefLink[PlotPoints, paclet:ref/PlotPoints]) and (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) will often catch such features.

Themes that affect curves include:

The arguments supplied to functions in (RefLink[MeshFunctions, paclet:ref/MeshFunctions]) and (RefLink[RegionFunction, paclet:ref/RegionFunction]) are x, y. Functions in (RefLink[ColorFunction, paclet:ref/ColorFunction]) are by default supplied with scaled versions of these arguments.

(RefLink[ScalingFunctions, paclet:ref/ScalingFunctions])->"scale" scales the y coordinate; (RefLink[ScalingFunctions, paclet:ref/ScalingFunctions])->{"scalex","scaley"} scales both the x and y coordinates.

OpenersPrimaryExamplesSection(Spacer1)Examples  (171)

OpenersExampleSection0(Spacer1)Basic Examples  (5)

Plot a function:

Plot[Sin[x],{x,0,6Pi}]

Plot several functions with a legend:

Plot[{Sin[x],Sin[2x],Sin[3x]},{x,0,2Pi},PlotLegends->"Expressions"]

Label each curve:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},PlotLabels->"Expressions"]

Fill below a curve:

Plot[2Sin[x]+x,{x,0,15},Filling->Bottom]

Fill between two curves:

Plot[{Sin[x]+x/2,Sin[x]+x}, {x, 0, 10},Filling->{1->{2}}]

Plot multiple filled curves, automatically using transparent colors:

Plot[Evaluate[Table[BesselJ[n,x],{n,4}]],{x,0,10},Filling->Axis]

OpenersExampleSection1(Spacer1)Scope  (27)

OpenersExampleSubsection0(Spacer1)Sampling  (9)

More points are sampled when the function changes quickly:

Plot[Sin[30Sin[x]],{x,0,10}]

The plot range is selected automatically:

Plot[1/x,{x,-1,1}]

Ranges where the function becomes nonreal are excluded:

Plot[Sqrt[x],{x,-1,1}]

The curve is split when there are discontinuities in the function:

Plot[Floor[Sqrt[x]],{x,0,100}]

Use (RefLink[Exclusions, paclet:ref/Exclusions])->(RefLink[None, paclet:ref/None]) to draw a connected curve:

Plot[Floor[Sqrt[x]],{x,0,100},Exclusions->None]

Use (RefLink[PlotPoints, paclet:ref/PlotPoints]) and (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) to control adaptive sampling:

Grid@Table[Plot[Sin[x],{x,0,15},PlotPoints->pp,MaxRecursion->mr],{mr,{0,1,2}},{pp,{5,10}}]

Use (RefLink[PlotRange, paclet:ref/PlotRange]) to focus in on areas of interest:

{Plot[x^4-x^2+1,{x,-2,2}],Plot[x^4-x^2+1,{x,-2,2},PlotRange->{0,2}]}

The domain can be specified by a region:

𝒟=ImplicitRegion[x≤-1∨x≥1,{x}];

Plot[Sin[x],{x}∈𝒟]

Specify a domain using a (RefLink[MeshRegion, paclet:ref/MeshRegion]):

𝒟=MeshRegion[{{-2},{-1},{-1/2},{1/2},{1},{2}},Line[{{1,2},{3,4},{5,6}}]];

Plot[x^3+1,{x}∈𝒟]

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

Plot[Abs[Gamma[z]],{z,-4,8},ScalingFunctions->"Log"]

OpenersExampleSubsection1(Spacer1)Labeling and Legending  (8)

Label curves with (RefLink[Labeled, paclet:ref/Labeled]):

Plot[Evaluate@Table[Labeled[x^n,x^n],{n,1,3}],{x,-3,3}]

Place the labels relative to the curves:

Table[Plot[Labeled[Cos[x],Cos[x],p],{x,0,2Pi},PlotLabel->p],{p,{Above,Below,Before,After}}]

Label curves with (RefLink[PlotLabels, paclet:ref/PlotLabels]):

Plot[{Sin[x],Sin[2x]},{x,0,6},PlotLabels->{Sin[x],Sin[2x]}]

Place the label near the curve at an x value:

Plot[Labeled[Sin[x],"sin(x)",3],{x,0,2π}]

Use a scaled position:

Plot[Labeled[Sin[x],"sin(x)",Scaled[0.25]],{x,0,2π}]

Specify the text position relative to the point:

Plot[Labeled[Sin[x],Sin[x],{Scaled[0.25],Above}],{x,0,2π}]

Label curves automatically with (RefLink[Callout, paclet:ref/Callout]):

Plot[{Callout[n^Sin[n],n^Sin[n]],Callout[n,n]},{n,0,20}]

Place a label with specific locations:

Plot[Callout[n^Sin[n],"label",Above],{n,1,10}]

Plot[Callout[n^Sin[n],"label",2],{n,1,10}]

Include legends for each curve:

Plot[{Sin[x],Cos[x]},{x,0,2π},PlotLegends->{Sin[x],Cos[x]}]

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

Plot[{Sin[x],Legended[Mean[{Sin[x],Cos[x]}],"average"],Cos[x]},{x,0,2π}]

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

Plot[{Sin[x],Legended[Mean[{Sin[x],Cos[x]}],Placed["average",Below]],Cos[x]},{x,0,2π}]

OpenersExampleSubsection2(Spacer1)Presentation  (10)

Multiple curves are automatically colored to be distinct:

Plot[{x^(1/4),x^(3/4),x^(3/2),x^(7/2)},{x,0,2}]

Provide explicit styling to different curves:

Plot[{x^(1/4),x^(3/4),x^(3/2),x^(7/2)},{x,0,2},PlotStyle->{Thick,Automatic,Red,Dashed}]

Include a legend:

Plot[{x^(1/4),x^(3/4),x^(3/2),x^(7/2)},{x,0,2},PlotStyle->{Thick,Automatic,Red,Dashed},PlotLegends->Automatic]

Add labels for the axes and overall plot:

Plot[Sin[x],{x,0,2Pi},AxesLabel->{x,y},PlotLabel->Sin[x]]

Add labels for the curves:

Plot[{x,x^2,x^3},{x,-2,2},PlotLabels->Automatic]

Label positions along a curve:

Plot[Labeled[x^4-25 x^2+20 x+15,{"abs max","abs min","rel max","rel min"},{Above,Below,0.5,3.5}],{x,-5,5}]

Provide an interactive (RefLink[Tooltip, paclet:ref/Tooltip]) for each curve:

Plot[{Tooltip[Sin[x]],Tooltip[Sin[2x]]},{x,0,2Pi}]

Create filled plots:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->Axis]

Use a plot theme:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},PlotTheme->"Marketing"]

Create an overlay mesh:

Plot[Sin[x],{x,0,2Pi},Mesh->20]

Style the curve segments between mesh points:

Plot[Sin[x],{x,0,2Pi},Mesh->10,MeshShading->{Red,None,Blue}]

OpenersExampleSection2(Spacer1)Options  (110)

OpenersExampleSubsection3(Spacer1)AspectRatio  (1)

Choose the ratio of height to width from the actual plot values:

{Plot[Sqrt[1-x^2],{x,0,1}],Plot[Sqrt[1-x^2],{x,0,1},AspectRatio->Automatic]}

OpenersExampleSubsection4(Spacer1)Axes  (2)

Draw no axes:

Plot[Sinc[x],{x,0,10},Axes->False]

Draw the y axis but no x axis:

Plot[Sinc[x],{x,0,10},Axes->{False,True}]

OpenersExampleSubsection5(Spacer1)AxesLabel  (2)

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

Plot[Sinc[u],{u,0,10},AxesLabel->Automatic]

Specify a label for each axis:

Plot[Sinc[x],{x,0,10},AxesLabel->{x,Sinc[x]}]

OpenersExampleSubsection6(Spacer1)AxesOrigin  (2)

Determine where the axes cross automatically:

Plot[1/(x-1)+2,{x,-2,4},AxesOrigin->Automatic]

Specify the axes origin at the point (1,2):

Plot[1/(x-1)+2,{x,-2,4},AxesOrigin->{1,2}]

OpenersExampleSubsection7(Spacer1)AxesStyle  (1)

Specify the style of each axis:

Plot[Sinc[x],{x,0,10},AxesStyle->{Directive[Thick,Dashed,Red],Blue}]

OpenersExampleSubsection8(Spacer1)BaselinePosition  (1)

Align graphs by the x axis in each plot:

{Plot[Im[Zeta[1/2+I t]],{t,-20,20},BaselinePosition->Axis],Plot[Re[Zeta[1/2+I t]],{t,-20,20},BaselinePosition->Axis]}

OpenersExampleSubsection9(Spacer1)ClippingStyle  (5)

Omit clipped regions of the plot:

Plot[Sin[x]/x^2,{x,-10,10},ClippingStyle->None]

Show the clipped regions like the rest of the curve:

Plot[Sin[x]/x^2,{x,-10,10},ClippingStyle->Automatic]

Show clipped regions with red lines:

Plot[Sin[x]/x^2,{x,-10,10},ClippingStyle->Red]

Show clipped regions as red at the bottom and thick at the top:

Plot[Sin[x]/x^2,{x,-10,10},ClippingStyle->{Red,Thick}]

Show clipped regions as red and thick:

Plot[Sin[x]/x^2,{x,-10,10},ClippingStyle->Directive[Red,Thick]]

OpenersExampleSubsection10(Spacer1)ColorFunction  (5)

Color by a scaled y coordinate and scaled x coordinate, respectively:

{Plot[Sinc[x],{x,0,10},ColorFunction->Function[{x,y},Hue[y]]],Plot[Sinc[x],{x,0,10},ColorFunction->Function[{x,y},Hue[x]]]}

Color with a named color scheme:

Plot[Sinc[x],{x,0,10},ColorFunction->"DarkRainbow"]

Color a curve red when its absolute y coordinate is above 0:

Plot[Sinc[x],{x,0,10},ColorFunction->Function[{x,y},If[y>0,Red,Black]],ColorFunctionScaling->False,PlotStyle->Thick]

Fill with the color used for the curve:

Plot[Sin[x],{x,0,2Pi},ColorFunction->Function[{x,y},Hue[y]],Filling->Axis]

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

Plot[Sinc[x],{x,0,10},ColorFunction->"DarkRainbow",PlotStyle->Directive[Red,Thick]]

OpenersExampleSubsection11(Spacer1)ColorFunctionScaling  (3)

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

Table[Plot[Sin[4Pi x],{x,0,1/2},PlotStyle->Thick,ColorFunction->Function[{x,y},Hue[x]],ColorFunctionScaling->cf],{cf,{False,True}}]

Color a curve red when its absolute y coordinate is above 0:

Plot[Sinc[x],{x,0,10},ColorFunction->Function[{x,y},If[y>0,Red,Black]],ColorFunctionScaling->False,PlotStyle->Thick]

Use hue to indicate x direction and brightness to indicate amplitude:

Plot[Sin[2x],{x,0,2Pi},ColorFunction->Function[{x,y},Hue[x,1,Abs[y]]],ColorFunctionScaling->{True,False},PlotStyle->Thick]

OpenersExampleSubsection12(Spacer1)Epilog  (2)

This inserts the graphics object in the resulting graphic:

Plot[Sin[x],{x,0,2Pi},Epilog->{PointSize[0.04],Point[{0,0}],Point[{Pi,0}],Point[{2Pi,0}]}]

Insert special markers to indicate whether a point belongs to the curve or not:

Plot[Floor[x], {x,-2,3}, Epilog-> {Table[Disk[{i,i},Offset[2.]],{i,-2,2}],Table[{EdgeForm[Black],White,Disk[{i+1,i},Offset[2]]}, {i,-2,2}]}]

OpenersExampleSubsection13(Spacer1)EvaluationMonitor  (3)

Find the list of values sampled by (RefLink[Plot, paclet:ref/Plot]):

Reap[Plot[Sin[x],{x,0,10},EvaluationMonitor:>Sow[x]];]//Short

Show where (RefLink[Plot, paclet:ref/Plot]) evaluates (RefLink[Sin, paclet:ref/Sin])[x]:

data=Reap[ Plot[ Sin[x], {x, 0, 2Pi}, EvaluationMonitor :> Sow[{x, Sin[x]}]] ][[-1,1]];

ListPlot[data ,Filling->Axis]

Count how many times the function is evaluated:

Block[{k=0},Plot[Sin[x],{x,0,2Pi},EvaluationMonitor:>k++];k]

OpenersExampleSubsection14(Spacer1)Exclusions  (7)

Use automatic methods for computing exclusions, in this case for a piecewise function:

Plot[Floor[x^2],{x,0,5}]

In this case, the exclusion comes from a branch cut discontinuity:

Plot[Im[Sqrt[-1+I (y+1)]],{y,-2,0}]

Indicate that no exclusions should be computed:

Plot[Im[Sqrt[-1+I (y+1)]],{y,-2,0},Exclusions->None]

Exclude a fixed set of points:

Plot[Tan[x],{x,-2,2},Exclusions->{-Pi/2,Pi/2}]

Give a set of exclusions as an equation:

Plot[1/(x^3-x+1),{x,-2,2},Exclusions->{x^3-x+1==0}]

This gives two sets of exclusions:

Plot[Tan[x^3-x+1]+1/(x+3Exp[x]),{x,-2,2},Exclusions->{Cos[x^3-x+1]==0,x+3Exp[x]==0}]

Exclude an equation and the automatically chosen points:

Plot[Floor[Tan[x]],{x,-2,2},Exclusions->{Automatic,Cos[x]==0}]

OpenersExampleSubsection15(Spacer1)ExclusionsStyle  (2)

Use dashed lines to indicate the vertical asymptotes:

Plot[Tan[x],{x,0,10},Exclusions->{Cos[x]==0},ExclusionsStyle->Dashing[Small]]

Use black points to highlight the exclusions:

Plot[Floor[x],{x,0,5},ExclusionsStyle->{None,Black}]

OpenersExampleSubsection16(Spacer1)Filling  (7)

Use symbolic or explicit values:

Table[Plot[Sin[x],{x,0,2Pi},Filling->f],{f,{Axis,Top,Bottom,0.3}}]

By default, overlapping fills combine using opacity:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->Axis]

Fill between curve 1 and the x axis:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->{1->Axis}]

Fill between curves 1 and 2:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->{1->{2}}]

Fill between curves 1 and 2 with a specific style:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->{1->{{2},Yellow}}]

Fill between curves 1 and y==(1/2) with yellow:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->{1->{1/2,Yellow}}]

Fill between curves 1 and 2; use yellow when 1 is below 2 and green when 1 is above 2:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->{1->{{2},{Yellow,Green}}}]

OpenersExampleSubsection17(Spacer1)FillingStyle  (4)

Use different fill colors:

Table[Plot[Sin[x],{x,0,2Pi},Filling->Axis,FillingStyle->c],{c,{Red,Green,Blue,Yellow}}]

Fill with opacity 0.5 orange:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},Filling->Axis,FillingStyle->Directive[Opacity[0.5],Orange]]

Fill with red below the x axis and blue above:

Plot[Sin[x],{x,0,2Pi},Filling->Axis,FillingStyle->{Red,Blue}]

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

Plot[Sin[x],{x,0,2Pi},ColorFunction->Function[{x,y},Hue[y]],Filling->Axis,FillingStyle->Automatic]

OpenersExampleSubsection18(Spacer1)LabelingSize  (4)

Textual labels are shown at their actual sizes:

Plot[{Sin[x]+x,x Log[x]},{x,0,5},PlotLabels->{"barcarole","perilously"}]

Image labels are automatically resized:

Plot[{Sin[x]+x,x Log[x]},{x,0,5},PlotLabels->{,}]

Specify a maximum size for textual labels:

Plot[{Sin[x]+x,x Log[x]},{x,0,5},PlotLabels->{"barcarole","perilously"},LabelingSize->30]

Specify a maximum size for image labels:

Plot[{Sin[x]+x,x Log[x]},{x,0,5},PlotLabels->{,},LabelingSize->50]

Show image labels at their natural sizes:

Plot[{Sin[x]+x,x Log[x]},{x,0,5},PlotLabels->{,},LabelingSize->Full]

OpenersExampleSubsection19(Spacer1)MaxRecursion  (2)

The default sampling mesh:

Plot[Sin[1/x],{x,0.001,0.1},Mesh->All]

Each level of (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) will subdivide the initial mesh into a finer mesh:

Table[ Plot[Sin[1/x],{x,0.001,0.1},MaxRecursion->i,Mesh->All,Ticks->None],{i,{0,3,6}}]

OpenersExampleSubsection20(Spacer1)Mesh  (3)

Show the initial and final sampling meshes:

{Plot[Sin[x],{x,0,2Pi},Mesh->Full],
Plot[Sin[x],{x,0,2Pi},Mesh->All]}

Use 20 mesh levels evenly spaced in the x direction:

Plot[Sin[x],{x,0,2Pi},Mesh->20]

Use an explicit list of values for the mesh in the x direction:

Plot[Sin[x],{x,0,2Pi},Mesh->{Range[0,2Pi,Pi/4]},MeshStyle->PointSize[Medium]]

OpenersExampleSubsection21(Spacer1)MeshFunctions  (2)

Use a mesh evenly spaced in the x and y directions:

Table[Plot[Tan[x],{x,0,Pi/2},MeshFunctions->{f},Mesh->20],{f,{Function[{x,y},x],Function[{x,y},y]}}]

Show 5 mesh levels in the x direction (red) and 10 in the y direction (blue):

Plot[Tan[x],{x,0,Pi/2},Mesh->{5,10},MeshFunctions->{#1&,#2&},MeshStyle->{Directive[PointSize[Medium],Red],Blue}]

OpenersExampleSubsection22(Spacer1)MeshShading  (6)

Alternate red and blue segments of equal width in the x direction:

Plot[Sin[x],{x,0,2Pi},Mesh->10,MeshFunctions->{#1&},MeshShading->{Red,Blue}]

Use (RefLink[None, paclet:ref/None]) to remove segments:

Plot[Sin[x],{x,0,2Pi},Mesh->10,MeshFunctions->{#1&},MeshShading->{Red,None}]

(RefLink[MeshShading, paclet:ref/MeshShading]) can be used with (RefLink[PlotStyle, paclet:ref/PlotStyle]):

Plot[Sin[x],{x,0,2Pi},Mesh->10,PlotStyle->Thick,MeshFunctions->{#1&},MeshShading->{Red,Blue}]

(RefLink[MeshShading, paclet:ref/MeshShading]) has higher priority than (RefLink[PlotStyle, paclet:ref/PlotStyle]) for styling the curve:

Plot[Sin[x],{x,0,2Pi},Mesh->10,PlotStyle->Green,MeshFunctions->{#1&},MeshShading->{Red,Blue}]

Use (RefLink[PlotStyle, paclet:ref/PlotStyle]) for some segments by setting (RefLink[MeshShading, paclet:ref/MeshShading]) to (RefLink[Automatic, paclet:ref/Automatic]):

Plot[Sin[x],{x,0,10},Mesh->10,PlotStyle->Directive[Thick,Yellow],MeshFunctions->{#1&},MeshShading->{Red,Automatic}]

(RefLink[MeshShading, paclet:ref/MeshShading]) can be used with (RefLink[ColorFunction, paclet:ref/ColorFunction]):

Plot[Sin[x],{x,0,10},Mesh->10,PlotStyle->Thick,MeshFunctions->{#1&},MeshShading->{Black,Automatic},
ColorFunction->Function[{x,y},Hue[x]]]

OpenersExampleSubsection23(Spacer1)MeshStyle  (4)

Color the mesh the same color as the plot:

Plot[Sin[x],{x,0,2Pi},Mesh->10,MeshStyle->Automatic]

Use a red mesh in the x direction:

Plot[Sin[x],{x,0,2Pi},Mesh->10,MeshStyle->Red]

Use a red mesh in the x direction and a blue mesh in the y direction:

Plot[Sin[x],{x,0,2Pi},Mesh->10,MeshStyle->{Red,Blue},MeshFunctions->{#1&,#2&}]

Use big, red mesh points in the x direction:

Plot[Sin[x],{x,0,2Pi},Mesh->10,MeshStyle->Directive[PointSize[Large],Red]]

OpenersExampleSubsection24(Spacer1)PerformanceGoal  (2)

Generate a higher-quality plot:

Timing[Plot[Sin[1/x],{x,0,.01},PerformanceGoal->"Quality"]]

Emphasize performance, possibly at the cost of quality:

Timing[Plot[Sin[1/x],{x,0,.01},PerformanceGoal->"Speed"]]

OpenersExampleSubsection25(Spacer1)PlotLabel  (1)

Add an overall label to the plot:

Plot[Exp[x],{x,0,3},PlotLabel->"exponential function"]

OpenersExampleSubsection26(Spacer1)PlotLabels  (5)

Specify text to label curves:

Plot[{Sin[x],Cos[x]},{x,0,2π},PlotLabels->{"sine","cosine"}]

Place the labels above the curves:

Plot[{Sin[x],Cos[x]},{x,0,2π},PlotLabels->Placed[{"sine","cosine"},Above]]

Place the labels differently for each curve:

Plot[{Sin[x],Cos[x]},{x,0,2π},PlotLabels->{Placed["sine",Below],Placed["cosine",Above]}]

(RefLink[PlotLabels, paclet:ref/PlotLabels])->"Expressions" uses functions as curve labels:

Plot[{Sin[x],Cos[x]},{x,0,2π},PlotLabels->"Expressions"]

Use callouts to identify the curves:

Plot[{Sin[x],Cos[x]},{x,0,2π},PlotLabels->{Callout["sin",{Scaled[0.25],Above}],Callout["cos",{Scaled[0.5],Below}]}]

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

Plot[{Sin[x],Cos[x]},{x,0,2π},PlotLabels->{"sine",None}]

OpenersExampleSubsection27(Spacer1)PlotLegends  (7)

No legends are used by default:

Plot[{Sin[x],Cos[x]},{x,0,10}]

Create a legend based on the functions:

Plot[{Sin[x],Cos[x]},{x,0,10},PlotLegends->"Expressions"]

Create a legend with placeholder text:

Plot[{Sin[x],Cos[x]},{x,0,10},PlotLegends->"Placeholder"]

Create a legend with specific labels:

Plot[{Sin[x],Cos[x]},{x,0,10},PlotLegends->{"one","two"}]

(RefLink[PlotLegends, paclet:ref/PlotLegends]) picks up (RefLink[PlotStyle, paclet:ref/PlotStyle]) values automatically:

Plot[{Sin[x],Cos[x]},{x,0,10},PlotStyle->{Red,Blue},PlotLegends->"Placeholder"]

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

Plot[{Sin[x],Cos[x]},{x,0,10},PlotStyle->{Red,Blue},PlotLegends->Placed["Placeholder",Below]]

Place legends inside:

Plot[{x,Sqrt[x]},{x,0,5},PlotStyle->{Red,Blue},PlotLegends->Placed["Expressions",{0.25,0.75}]]

Use (RefLink[LineLegend, paclet:ref/LineLegend]) to modify the appearance of the legend:

Plot[{Sin[x],Cos[x]},{x,0,10},PlotLegends->LineLegend["Expressions",LegendFunction->Frame]]

OpenersExampleSubsection28(Spacer1)PlotPoints  (1)

Use more initial points to get a smoother curve:

Table[Plot[Sin[x],{x,0,2Pi},PlotPoints->i,MaxRecursion->0],{i,{5,10,15,25}}]

OpenersExampleSubsection29(Spacer1)PlotRange  (3)

Show the curve over the whole domain:

Plot[Sqrt[x],{x,-5,5},PlotRange->Full]

Show the curve only where it is real valued:

Plot[Sqrt[x],{x,-5,5},PlotRange->Automatic]

Show the curve from y==-2 to y==2 over the whole domain:

Plot[Sqrt[x],{x,-5,5},PlotRange->2]

OpenersExampleSubsection30(Spacer1)PlotRangeClipping  (2)

Constrain the curve to the framed region:

Plot[1/x,{x,-2,2},Frame->True]

Draw the curve using the whole graphical region:

Plot[1/x,{x,-2,2},Frame->True,PlotRangeClipping->False]

OpenersExampleSubsection31(Spacer1)PlotStyle  (6)

Use different style directives:

Table[Plot[Sin[x],{x,0,2Pi},PlotStyle->ps],{ps,{Red,Thick,Dashed,Directive[Red,Thick]}}]

By default, different styles are chosen for multiple curves:

Plot[{Sin[x],Sin[2x],Sin[3x]},{x,0,2Pi}]

Explicitly specify the style for different curves:

Plot[{Sin[x],Sin[2x],Sin[3x]},{x,0,2Pi},PlotStyle->{Red,Green,Blue}]

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

Plot[Sin[x],{x,0,2Pi},PlotStyle->Thick,ColorFunction->Function[{x,y},Hue[y]]]

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

Plot[Sin[x],{x,0,2Pi},PlotStyle->Directive[Opacity[0.5],Thick],Mesh->10,MeshFunctions->{#1&},MeshShading->{Red,Blue}]

(RefLink[MeshStyle, paclet:ref/MeshStyle]) by default uses the same style as (RefLink[PlotStyle, paclet:ref/PlotStyle]):

Plot[Sin[x],{x,0,2Pi},PlotStyle->Red,Mesh->All]

OpenersExampleSubsection32(Spacer1)PlotTheme  (2)

Use a theme with simple ticks and grid lines in a bright color scheme:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},PlotTheme->"Business"]

Change the color scheme:

Plot[{Sin[x],Cos[x]},{x,0,2Pi},PlotTheme->"Business",PlotStyle->96]

OpenersExampleSubsection33(Spacer1)RegionFunction  (2)

Show the curve where (π/2)<x (mod 2 π)<((3 π)/2):

Plot[Sin[x],{x,0,8Pi},RegionFunction->Function[{x,y},Pi/2<Mod[x,2Pi]<3Pi/2]]

Exclude the region where -(1/2)<y<(1/2):

Plot[Sin[x],{x,0,8Pi},RegionFunction->Function[{x,y},Abs[y]>0.5]]

OpenersExampleSubsection34(Spacer1)ScalingFunctions  (9)

By default, plots have linear scales in each direction:

Plot[x^2,{x,0,10}]

Use a log scale in the y direction:

Plot[x^2,{x,0,10},ScalingFunctions->"Log"]

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

Plot[x^2,{x,0,10},ScalingFunctions->"Reverse"]

Use a reciprocal scale in the y direction:

Plot[x^2,{x,1,10},ScalingFunctions->"Reciprocal"]

Use different scales in the x and y directions:

Plot[x^2,{x,0,10},ScalingFunctions->{"Reverse","Log"}]

Reverse the x axis without changing the y axis:

Plot[x^2,{x,0,10},ScalingFunctions->{"Reverse",None}]

Use a scale defined by a function and its inverse:

Plot[x^2,{x,0,10},ScalingFunctions->{None,{-Log[#]&,Exp[-#]&}}]

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

Plot[x^2,{x,1,10},ScalingFunctions->"Log",Ticks->{Automatic,2^Range[10]},GridLines->{None,2^Range[10]}]

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

Plot[x^2,{x,1,10},ScalingFunctions->"Log",PlotRange->{1,100},AxesOrigin->{Automatic,10}]

OpenersExampleSubsection35(Spacer1)WorkingPrecision  (2)

Evaluate functions using machine-precision arithmetic:

Plot[Sin[x+10^20],{x,0,2Pi},WorkingPrecision->MachinePrecision]

Evaluate functions using arbitrary-precision arithmetic:

Plot[Sin[x+10^20],{x,0,2Pi},WorkingPrecision->20]

OpenersExampleSection3(Spacer1)Applications  (19)

OpenersExampleSubsection36(Spacer1)Basic Applications  (3)

Compare several functions:

Plot[{(x^(1/2)),x,(x^2)},{x,0,2},PlotLegends->"Expressions"]

A function and its inverse are reflections in y==x:

Plot[{Exp[x],Log[x],x},{x,-3,3},PlotRange->3,PlotStyle->{Red,Green,Dashed}, AspectRatio->Automatic]

Illustrate that -(RefLink[Abs, paclet:ref/Abs])[x]≤x (RefLink[Sin, paclet:ref/Sin])[1/x]≤(RefLink[Abs, paclet:ref/Abs])[x] in the interval:

Plot[{x Sin[1/x],Abs[x],-Abs[x]}, {x,-1/2,1/2}, PlotStyle->{Red,Directive[Dashed,Gray],Directive[Dashed,Gray]}]

OpenersExampleSubsection37(Spacer1)Highlighting Discrete Function Features  (8)

Curves are broken where a function has singularities:

Plot[Tan[x],{x,-5,5}]

Emphasize the singularities by specifying (RefLink[ExclusionsStyle, paclet:ref/ExclusionsStyle]):

Plot[Tan[x],{x,-5,5},ExclusionsStyle->Dashed]

Highlight the discontinuities in a function f(x) using (RefLink[ExclusionsStyle, paclet:ref/ExclusionsStyle]):

Plot[Sin[Floor[x]],{x,0,10},ExclusionsStyle->Dotted]

The discontinuities are automatically derived but can also be specified:

Plot[Sin[Floor[x]],{x,0,10},Exclusions->{Sin[π x]==0},ExclusionsStyle->Dashed]

Highlight zeros of a function f(x):

Plot[Sin[(Sqrt[2])x]+Sin[x],{x,0,20}]

The second argument passed to (RefLink[MeshFunctions, paclet:ref/MeshFunctions]) is f(x):

Plot[Sin[(Sqrt[2])x]+Sin[x],{x,0,20},MeshFunctions->{Function[{x,y},y]},Mesh->{{0}},MeshStyle->Directive[PointSize[Medium],Red]]

Highlight local extrema for a function f(x) using (RefLink[MeshFunctions, paclet:ref/MeshFunctions]):

Plot[Sin[(Sqrt[2])x]+Sin[x],{x,0,50}]

Local extrema are given by f'(x)==0:

mf=Function[{x,y},Evaluate@D[Sin[(Sqrt[2])x]+Sin[x],x]];

Plot[Sin[(Sqrt[2])x]+Sin[x],{x,0,50},MeshFunctions->{mf},Mesh->{{0}},MeshStyle->Directive[PointSize[Medium],Red]]

Highlight the local maximums and minimums of a function f(x):

f=Sin[(Sqrt[2])x]+Sin[x];

Plot[f,{x,0,50}]

The local maximums are the points where ((∂f(x))/(∂x))==0 and (((∂^2)f(x))/(∂(x^2)))≤0:

Plot[f,{x,0,50},Exclusions->{{D[f,x]==0,D[f,{x,2}]≤0}},ExclusionsStyle->Directive[Thickness[0.02],Red]]

Similarly the local minimums are given by ((∂f(x))/(∂x))==0 and (((∂^2)f(x))/(∂(x^2)))≥0:

Plot[f,{x,0,50},Exclusions->{{D[f,x]==0,D[f,{x,2}]≥0}},ExclusionsStyle->Directive[Thickness[0.02],Purple]]

Highlight the non-negative and non-positive parts of a function f(x):

f=Sin[(Sqrt[2])x]+Sin[x];

Plot[f,{x,0,50}]

Using the (RefLink[Filling, paclet:ref/Filling]) specification allows this to be readily achieved:

Plot[f,{x,0,50},Filling->{{1->{0,{Red,Blue}}}},PlotLegends->SwatchLegend[{Blue,Red},{"non-negative","non-positive"}]]

Highlight the segments where the function f(x) is increasing or decreasing:

f=Sin[(Sqrt[2])x]+Sin[x];

plot=Plot[f,{x,0,50}]

A function is increasing when ((∂f(x))/(∂x))≥0:

rfi=Function[{x,y},Evaluate[D[f,x]≥0]];

incr=Plot[f,{x,0,50},RegionFunction->rfi,PlotStyle->Blue]

A function is decreasing when ((∂f(x))/(∂x))≤0:

rfd=Function[{x,y},Evaluate[D[f,x]≤0]];

decr=Plot[f,{x,0,50},RegionFunction->rfd,PlotStyle->Red]

Show them together and add a legend:

Legended[Show[incr,decr],SwatchLegend[{Blue,Red},{"increasing","decreasing"}]]

Highlight the parts where a function f(x) is convex or concave:

f=Sin[(Sqrt[2])x]+Sin[x];

plot=Plot[f,{x,0,50}]

A function is convex when (((∂^2)f(x))/(∂(x^2)))≥0:

rfcvx=Function[{x,y},Evaluate[D[f,{x,2}]≥0]];

cvx=Plot[f,{x,0,50},RegionFunction->rfcvx,PlotStyle->Orange]

A function is concave when (((∂^2)f(x))/(∂(x^2)))≤0:

rfccv=Function[{x,y},Evaluate[D[f,{x,2}]≤0]];

ccv=Plot[f,{x,0,50},RegionFunction->rfccv,PlotStyle->Blue]

Show them together with a legend:

Legended[Show[cvx,ccv],SwatchLegend[{Orange,Blue},{"convex","concave"}]]

OpenersExampleSubsection38(Spacer1)Highlighting Continuous Function Features  (1)

Use color to overlay the derivative f'(x) of function on top of the curve for f(x):

f=Sin[(Sqrt[2])x]+Sin[x];

Plot[f,{x,0,20}]

By rescaling the derivative to be between 0 and 1, you can easily map to a color:

{min,max}={NMinValue[{D[f,x],0≤x≤20},x],NMaxValue[{D[f,x],0≤x≤20},x]};

df=Rescale[D[f,x],{min,max},{0,1}]

Plot[df,{x,0,20}]

From (RefLink[ColorData, paclet:ref/ColorData]) you can get a variety of color scales:

cf=Function[{x},Evaluate[ColorData["Rainbow"][ df]]]

leg=BarLegend[{ColorData["Rainbow"][Rescale[#,{min,max},{0,1}]]&,{min,max}},LegendMarkerSize->150];

The derivative can now be overlaid as color on top of the curve using (RefLink[ColorFunction, paclet:ref/ColorFunction]):

Plot[f,{x,0,20},ColorFunction->cf,ColorFunctionScaling->False,PlotLegends->leg]

Using (RefLink[Filling, paclet:ref/Filling]) emphasizes the color more:

Plot[f,{x,0,20},ColorFunction->cf,ColorFunctionScaling->False,Filling->0,PlotLegends->leg]

OpenersExampleSubsection39(Spacer1)Epigraph and Hypograph of a Function  (2)

The epigraph of a function f(x) is given by {{x,y}|f(x)≤y}. You can visualize the epigraph by using (RefLink[Filling, paclet:ref/Filling]):

Plot[Sin[x],{x,0,2π},Filling->{1->Top},PlotRange->2]

The hypograph of a function f(x) is given by {{x,y}|f(x)≥y}. You can visualize the hypograph by using (RefLink[Filling, paclet:ref/Filling]):

Plot[Sin[x],{x,0,2π},Filling->{1->Bottom},PlotRange->2]

OpenersExampleSubsection40(Spacer1)Complex-Valued Functions  (3)

Plot the real and imaginary parts of a complex-valued function of a real variable:

Plot[{Re[Exp[I ω]],Im[Exp[I ω]]},{ω,0,10},PlotLegends->"Expressions"]

Plot the magnitude and phase of a complex-valued function of a real variable:

Plot[{Abs[Exp[I ω]/(1+(ω^2))],Arg[Exp[I ω]/(1+(ω^2))]},{ω,-π,π},PlotLegends->"Expressions"]

Plot the magnitude and color based on the phase of the function:

f=Exp[I ω]/(1+(ω^2));
cf=Function[ω,Evaluate[Hue[Arg[f]/(2π),0.5]]]

Plot[Abs[f],{ω,-π,π},ColorFunction->cf,ColorFunctionScaling->False]

Add filling and a color legend that provides a separate axis for the phase:

Plot[Abs[f],{ω,-π,π},ColorFunction->cf,ColorFunctionScaling->False,Filling->Bottom,PlotLegends->BarLegend[{cf,{-π,π}},LegendMarkerSize->150]]

OpenersExampleSubsection41(Spacer1)Equation Solutions  (2)

The general solution to a differential equation:

s=DSolve[y'[x]==(1/(1+y[x])),y, x]

Plot two particular solutions:

Plot[Evaluate[y[x]/.s/.(C[1])->0], {x, -2, 5}]

Plot a family of solutions:

Plot[Evaluate[y[x]/.s/.(C[1])->Range[0,5]], {x,-5,5}]

The general solution to an algebraic equation:

s=Reduce[Sin[x^2+y]==0,{x,y}]

Plot a family of solutions:

Plot[Evaluate[{-(x^2)+2 π (C[1]), π-(x^2)+2 π (C[1])}/.(C[1])->Range[-5,5]],{x,-5,5}]

OpenersExampleSection4(Spacer1)Properties & Relations  (9)

(RefLink[Plot, paclet:ref/Plot]) samples more points where it needs to:

Plot[Sin[x],{x,0,10},Mesh->All]

(RefLink[Plot, paclet:ref/Plot]) is a special case of (RefLink[ParametricPlot, paclet:ref/ParametricPlot]) for curves:

{Plot[Sin[x^2],{x,0,5}],ParametricPlot[{x,Sin[x^2]},{x,0,5},AspectRatio->1/GoldenRatio]}

Use (RefLink[ParametricPlot, paclet:ref/ParametricPlot]) for parametric curves and regions:

{ParametricPlot[{Cos[θ],Sin[θ]},{θ,0,2Pi}],ParametricPlot[{r Cos[θ],r Sin[θ]},{θ,0,2Pi},{r,1,2}]}

Use (RefLink[ContourPlot, paclet:ref/ContourPlot]) and (RefLink[RegionPlot, paclet:ref/RegionPlot]) for implicit curves and regions:

{ContourPlot[x^2+y^2==1,{x,-1,1},{y,-1,1}],RegionPlot[1<x^2+y^2<4,{x,-2,2},{y,-2,2}]}

Use (RefLink[LogPlot, paclet:ref/LogPlot]), (RefLink[LogLinearPlot, paclet:ref/LogLinearPlot]), and (RefLink[LogLogPlot, paclet:ref/LogLogPlot]) for logarithmic plots:

LogLogPlot[Abs[10^2/((I ω)^2+100)],{ω,10^0,10^5}]

Use (RefLink[ListPlot, paclet:ref/ListPlot]) and (RefLink[ListLinePlot, paclet:ref/ListLinePlot]) for data:

{ListLinePlot[Table[{x,Sin[x]},{x,0,10,0.25}]],Plot[Sin[x],{x,0,10}]}

(RefLink[AbsArgPlot, paclet:ref/AbsArgPlot]) is a special case of (RefLink[Plot, paclet:ref/Plot]):

{Plot[Abs[ArcSin[x]],{x,-3,3}],
AbsArgPlot[ArcSin[x],{x,-3,3}]}

(RefLink[ReImPlot, paclet:ref/ReImPlot]) is a special case of (RefLink[Plot, paclet:ref/Plot]):

{Plot[ReIm[ArcSin[x]],{x,-3,3}],
ReImPlot[ArcSin[x],{x,-3,3}]}

Use (RefLink[Plot3D, paclet:ref/Plot3D]) and (RefLink[ParametricPlot3D, paclet:ref/ParametricPlot3D]) for function and parametric surfaces:

Plot3D[(x^2+y^2)Exp[-(x^2+y^2)],{x,-2,2},{y,-2,2}]

ParametricPlot3D[{-2 Cos[u] Cos[v]^3,-2 Cos[v]^2 Sin[u],2 Tan[v]},{u,0,2Pi},{v,-1,1}]

OpenersExampleSection5(Spacer1)Neat Examples  (1)

Eigenfunctions in a potential well:

f[n_,x_]:= Abs[((1/Pi)^(1/4)HermiteH[n,x])/(E^(x^2/2)Sqrt[2^n n!])]^2

Plot[Evaluate@
  Append[Table[f[n,x]+n+1/2,{n,0,7}],x^2/2],{x,-4,4},Filling->Table[n->n-1/2,{n,1,8}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ListLinePlot, paclet:ref/ListLinePlot])  ▪  (RefLink[DiscretePlot, paclet:ref/DiscretePlot])  ▪  (RefLink[ParametricPlot, paclet:ref/ParametricPlot])  ▪  (RefLink[LogPlot, paclet:ref/LogPlot])  ▪  (RefLink[LogLinearPlot, paclet:ref/LogLinearPlot])  ▪  (RefLink[LogLogPlot, paclet:ref/LogLogPlot])  ▪  (RefLink[PolarPlot, paclet:ref/PolarPlot])  ▪  (RefLink[Plot3D, paclet:ref/Plot3D])  ▪  (RefLink[ContourPlot, paclet:ref/ContourPlot])  ▪  (RefLink[AbsArgPlot, paclet:ref/AbsArgPlot])  ▪  (RefLink[ReImPlot, paclet:ref/ReImPlot])  ▪  (RefLink[Graphics, paclet:ref/Graphics])  ▪  (RefLink[Show, paclet:ref/Show])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Basic Plotting, paclet:tutorial/BasicPlotting])}, {▪(RefLinkPlain[Options for Graphics, paclet:tutorial/Options])}, {▪(RefLinkPlain[Graphics and Sound, paclet:tutorial/GraphicsAndSoundOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Function Visualization, paclet:guide/FunctionVisualization])}, {▪(RefLinkPlain[Precollege Education, paclet:guide/PrecollegeEducation])}, {▪(RefLinkPlain[Statistical Visualization, paclet:guide/StatisticalVisualization])}, {▪(RefLinkPlain[Differential Equations, paclet:guide/DifferentialEquations])}, {▪(RefLinkPlain[System Model Analytics & Design, paclet:guide/SystemModelAnalyticsDesign])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-FastIntro.png(Spacer1)Fast Introduction for Programmers: Graphics, http://www.wolfram.com/language/fast-introduction-for-programmers/graphics/])}})}})