({{, (RefLink[ListContourPlot, paclet:ref/ListContourPlot])[array]
generates a contour plot from an array of height values. }, {, (RefLink[ListContourPlot, paclet:ref/ListContourPlot])[{{(Subscript[x, 1]),(Subscript[y, 1]),(Subscript[f, 1])},{(Subscript[x, 2]),(Subscript[y, 2]),(Subscript[f, 2])},…}]
generates a contour plot from values defined at specified points. }})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ListContourPlot, paclet:ref/ListContourPlot])[array] arranges successive rows of array up the page, and successive columns across.

(RefLink[ListContourPlot, paclet:ref/ListContourPlot]) by default generates grayscale output, in which larger values are shown lighter.

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

(RefLink[ListContourPlot, paclet:ref/ListContourPlot]) linearly interpolates values to give smooth contours.

array should be a rectangular array of real numbers; holes will be left in the plot whenever there are elements that are not real numbers.

(RefLink[ListContourPlot, paclet:ref/ListContourPlot])[array] by default takes the x and y coordinate values for each data point to be successive integers starting at 1.

The setting (RefLink[DataRange, paclet:ref/DataRange])->{{(Subscript[x, min]),(Subscript[x, max])},{(Subscript[y, min]),(Subscript[y, max])}} specifies other ranges of coordinate values to use.

With the default setting (RefLink[DataRange, paclet:ref/DataRange])->(RefLink[Automatic, paclet:ref/Automatic]), (RefLink[ListContourPlot, paclet:ref/ListContourPlot])[{{(Subscript[a, 11]),(Subscript[a, 12]),(Subscript[a, 13])},…,{(Subscript[a, n 1]),(Subscript[a, n 2]),(Subscript[a, n 3])}}] will assume that the data being given is {{(Subscript[x, 1]),(Subscript[y, 1]),(Subscript[f, 1])},…}, rather than an n×3 array of values.

(RefLink[ListContourPlot, paclet:ref/ListContourPlot])[list,(RefLink[DataRange, paclet:ref/DataRange])->(RefLink[All, paclet:ref/All])] always takes list to represent an array of values.

For (RefLink[ListContourPlot, paclet:ref/ListContourPlot])[array], (RefLink[Mesh, paclet:ref/Mesh])->(RefLink[Full, paclet:ref/Full]) draws a mesh that crosses at the position of each data point.

In determining how to color regions between contour levels, (RefLink[ListContourPlot, paclet:ref/ListContourPlot]) looks first at any explicit setting given for (RefLink[ContourShading, paclet:ref/ContourShading]), then at the setting for (RefLink[ColorFunction, paclet:ref/ColorFunction]).

(RefLink[ListContourPlot, paclet:ref/ListContourPlot]) works with (RefLink[SparseArray, paclet:ref/SparseArray]) objects.

The arguments supplied to functions in (RefLink[MeshFunctions, paclet:ref/MeshFunctions]) and (RefLink[RegionFunction, paclet:ref/RegionFunction]) are x, y, f.

(RefLink[ColorFunction, paclet:ref/ColorFunction]) is by default supplied with a single argument, given by the average of the scaled values of f for each pair of successive contour levels.

Typical settings for (RefLink[PlotLegends, paclet:ref/PlotLegends]) include:

Possible settings for (RefLink[ScalingFunctions, paclet:ref/ScalingFunctions]) include:

Each scaling function (Subscript[s, i]) is either a string "scale" or {g,(g^(-1))}, where (g^(-1)) is the inverse of g.

(RefLink[ListContourPlot, paclet:ref/ListContourPlot]) returns (RefLink[Graphics, paclet:ref/Graphics])[(RefLink[GraphicsComplex, paclet:ref/GraphicsComplex])[data]].

OpenersPrimaryExamplesSection(Spacer1)Examples  (109)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Generate contours from an array of heights:

ListContourPlot[Table[Sin[i+j^2],{i,0,3,0.1},{j,0,3,0.1}]]

Give explicit x, y, z coordinates for the data:

data=Table[{x=RandomReal[{-2,2}],y=RandomReal[{-2,2}],Sin[x y]},{1000}];

ListContourPlot[data]

Generate contours over interpolated data with a legend:

ListContourPlot[RandomReal[1,{10,10}],InterpolationOrder->3,PlotLegends->Automatic]

OpenersExampleSection1(Spacer1)Scope  (15)

OpenersExampleSubsection0(Spacer1)Data  (8)

For regular data consisting of z values, the x and y data ranges are taken to be integer values:

ListContourPlot[Table[Sin[x y],{x,0,3,0.1},{y,0,3,0.1}],Mesh->All]

Provide explicit x and y data ranges by using (RefLink[DataRange, paclet:ref/DataRange]):

ListContourPlot[Table[Sin[x y],{x,0,3,0.1},{y,0,3,0.1}],DataRange->{{0,3},{0,3}}]

For irregular data consisting of (x,y,z) triples, the x and y data ranges are inferred from data:

data=Table[{x=RandomReal[{-1,1}],y=RandomReal[{-1,1}],x^2-y^2},{500}];

ListContourPlot[data,Mesh->All]

Areas around where the data is nonreal are excluded:

ListContourPlot[ReplacePart[Partition[Range[100],10],{{3,3}->None,{5,7}->I,{8,4}->Missing["NotAvailable"]}]]

ListContourPlot[Table[{x=RandomReal[{-1,1}],y=RandomReal[{-1,1}],Sqrt[1-x^2-y^2]},{1000}]]

Use (RefLink[MaxPlotPoints, paclet:ref/MaxPlotPoints]) to limit the number of points used:

Table[ListContourPlot[Table[Sin[x y],{x,0,3,0.075},{y,0,3,0.075}],MaxPlotPoints->mp,Mesh->All],{mp,{Infinity,20,10}}]

(RefLink[PlotRange, paclet:ref/PlotRange]) is selected automatically:

ListContourPlot[Table[1/(x^2+y^2),{x,-2,2,4/51},{y,-2,2,4/51}]]

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

{ListContourPlot[Table[x^4+y^4-x^2-y^2+1,{x,-2,2,0.1},{y,-2,2,0.1}]],ListContourPlot[Table[x^4+y^4-x^2-y^2+1,{x,-2,2,0.1},{y,-2,2,0.1}],PlotRange->{0,2},ClippingStyle->None]}

Use (RefLink[RegionFunction, paclet:ref/RegionFunction]) to restrict the density to a region given by inequalities:

data=Flatten[Table[{x,y,Sin[x^2+y^2]/(x^2+y^2)},{x,-4,4,0.2},{y,-4,4,0.2}],1];//Quiet

ListContourPlot[data,PlotRange->All,RegionFunction->Function[{x,y,z},Norm[{x,y}]<4]]

OpenersExampleSubsection1(Spacer1)Presentation  (7)

Add labels:

ListContourPlot[Table[Sin[i+j^2],{i,0,3,0.1},{j,0,3,0.1}],FrameLabel->{j,i},PlotLabel->Sin[i+j^2],ColorFunction->"SunsetColors"]

Color the density by height:

ListContourPlot[Table[Sin[i+j^2],{i,0,3,0.05},{j,0,3,0.05}],ColorFunction->Function[{z},Hue[z]]]

ListContourPlot[Table[Sin[i+j^2],{i,0,3,0.05},{j,0,3,0.05}],ColorFunction->"SolarColors"]

Include a legend:

ListContourPlot[Table[Sin[i+j^2],{i,0,3,0.05},{j,0,3,0.05}],ColorFunction->"Rainbow",PlotLegends->Automatic]

Label the contours:

ListContourPlot[Table[Sin[i^2+j^2],{i,-1,1,0.1},{j,-1,1,0.1}],ContourLabels->All,ColorFunction->"FruitPunchColors"]

ListContourPlot[Table[Sin[i^2+j^2],{i,-1,1,0.1},{j,-1,1,0.1}],ContourLabels->(Text[Style[#3,Hue[#3]],{#1,#2}]&),ColorFunction->GrayLevel]

Use specific colors between contours:

ListContourPlot[Table[Sin[i]Sin[j],{i,-3,3,0.05},{j,-3,3,0.05}],ContourShading->Hue/@Range[0,0.8,0.8/10],Contours->9]

ListContourPlot[Table[Sin[i]Sin[j],{i,-3,3,0.05},{j,-3,3,0.05}],ContourShading->Table[ColorData[29][i],{i,1,10}],Contours->9]

Use different styles for the contours:

ListContourPlot[Table[Sin[x y],{x,0,3,0.1},{y,0,3,0.1}],ContourStyle->{Red,Directive[Red,Dashed]}]

Use a theme with simple ticks and a legend:

ListContourPlot[Table[Sin[i]Sin[j],{i,-3,3,0.05},{j,-3,3,0.05}],PlotTheme->"Web"]

OpenersExampleSection2(Spacer1)Options  (73)

OpenersExampleSubsection2(Spacer1)BoundaryStyle  (4)

No boundary is used by default:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}]]

Use a red boundary around the edges of the contours:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}], BoundaryStyle->Red]

(RefLink[BoundaryStyle, paclet:ref/BoundaryStyle]) applies to holes cut by (RefLink[RegionFunction, paclet:ref/RegionFunction]):

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.05},{j,0,Pi,0.05}], BoundaryStyle->Red,RegionFunction->Function[{x,y,z},Abs[z]≥0.25]]

(RefLink[BoundaryStyle, paclet:ref/BoundaryStyle]) applies where there are jumps in the surface:

ListContourPlot[{{10,10,1},{6,8,10},{7,9,9},{1,1,2},{4,6,4},{7,4,9},{10,6,8}},InterpolationOrder->0,BoundaryStyle->Red]

OpenersExampleSubsection3(Spacer1)ClippingStyle  (4)

Clipped regions are not shown by default:

ListContourPlot[Table[Im[Gamma[x+I y]],{y,-3.5,3.5,0.1},{x,-3.5,3.5,0.1}]]

Color clipped regions like the rest of the surface:

ListContourPlot[Table[Im[Gamma[x+I y]],{y,-3.5,3.5,0.1},{x,-3.5,3.5,0.1}],ClippingStyle->Automatic]

Use pink to fill the clipped regions:

ListContourPlot[Table[Im[Gamma[x+I y]],{y,-3.5,3.5,0.1},{x,-3.5,3.5,0.1}],ClippingStyle->Pink]

Use light red where the surface is clipped above and pink below:

ListContourPlot[Table[Im[Gamma[x+I y]],{y,-3.5,3.5,0.1},{x,-3.5,3.5,0.1}],ClippingStyle->{Pink,LightRed}]

OpenersExampleSubsection4(Spacer1)ColorFunction  (2)

Color by scaled z coordinate:

ListContourPlot[Table[x+Sin[3x+y^2],{x,-3,3,0.1},{y,-3,3,0.1}],ColorFunction->Hue]

Named color gradients color in the z direction:

ListContourPlot[Table[x+Sin[3x+y^2],{x,-3,3,0.1},{y,-3,3,0.1}],ColorFunction->"Warm"]

OpenersExampleSubsection5(Spacer1)ColorFunctionScaling  (1)

Color with blue if contour values are negative, and with red otherwise:

ListContourPlot[Table[Sin[x]Sin[y],{x,0,2Pi,0.1},{y,0,2Pi,0.1}],ColorFunction->(If[#<0,Darker[Blue,Abs[#]],Lighter[Red,#]]&),ColorFunctionScaling->False]

OpenersExampleSubsection6(Spacer1)ContourLabels  (2)

Add labels to contour lines:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourLabels->All]

Label with values in a frame:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourLabels->Function[{x,y,z},Text[Framed[z],{x,y},Background->White]]]

OpenersExampleSubsection7(Spacer1)Contours  (7)

Use 7 equally spaced contours:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->7]

Use automatic contour selection:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->Automatic]

Use at most 5 automatically selected contours:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->{Automatic,5}]

Use specific contours:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->{-0.5,0.5}]

Use specific contours with specific styles:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->{{-0.5,Thick},{0.5,Dashed}}]

Use a function to generate a set of contours:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->Function[{min,max},Range[min,max,0.1]]]

Have contours at the 10% and 90% percentile values:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->Function[{min,max},Rescale[{0.1,0.9},{0,1},{min,max}]]]

OpenersExampleSubsection8(Spacer1)ContourShading  (4)

The automatic shading is darker at low values and lighter at high values:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourShading->Automatic]

Use (RefLink[None, paclet:ref/None]) to only show the contour lines:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourShading->None]

Shade between contours using a color function:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourShading->Automatic,ColorFunction->"Rainbow"]

Use an explicit list of colors between contours:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],Contours->3,ContourShading->{Red,Orange,Yellow,White}]

OpenersExampleSubsection9(Spacer1)ContourStyle  (5)

The default contour style is a partially transparent line:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourStyle->Automatic]

Use black contour lines:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourStyle->Black]

Use (RefLink[None, paclet:ref/None]) to not show contour lines:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourStyle->None]

Alternate between red and dashed contour lines:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourStyle->{Red,Dashed}]

Use dashed red contour lines:

ListContourPlot[Table[Sin[x]Sin[y],{x,-3,3,0.1},{y,-3,3,0.1}],ContourStyle->Directive[Red,Dashed]]

OpenersExampleSubsection10(Spacer1)DataRange  (4)

Arrays of height values are displayed against the number of elements in each direction:

ListContourPlot[Table[Sin[i+j^2],{i,0,Pi,0.1},{j,0,Pi,0.1}]]

Rescale to the sampling space:

ListContourPlot[Table[Sin[i+j^2],{i,0,Pi,0.1},{j,0,Pi,0.1}],DataRange->{{0,Pi},{0,Pi}}]

Triples are interpreted as x, y, z coordinates:

data=Table[Sin[i+j],{j,0,2Pi,0.5},{i,-1,1}];

ListContourPlot[data]

Generate an array of triples:

data=Table[Sin[i+j],{j,0,2Pi,0.5},{i,-1,1}];

ArrayPlot[Transpose@data]

Force interpretation as an array of height values:

ListContourPlot[data,DataRange->All]

ListContourPlot[data,DataRange->{{0,1},{0,1}}]

OpenersExampleSubsection11(Spacer1)InterpolationOrder  (5)

Contours are normally based on a linear interpolation of the data:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.5},{j,0,Pi,0.5}]]

Use zero-order or piecewise constant interpolation:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.5},{j,0,Pi,0.5}],InterpolationOrder->0]

Use third-order spline interpolation to fit the data:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.5},{j,0,Pi,0.5}],Mesh->None,InterpolationOrder->3,PlotRange->All]

Interpolation order 0 to 5:

Table[ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.5},{j,0,Pi,0.5}],Mesh->None,InterpolationOrder->i,Mesh->Full,PlotLabel->i,PlotRange->All],{i,0,5}]

With a limited number of points, irregular data is linearly interpolated:

data=Table[{x=RandomReal[5],y=RandomReal[5],Sin[x y]},{250}];

ListContourPlot[data,Contours->3,MaxPlotPoints->30]

Irregular data with (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder])->1 uses natural neighbor interpolation:

ListContourPlot[data,Contours->3,MaxPlotPoints->30,InterpolationOrder->1]

OpenersExampleSubsection12(Spacer1)MaxPlotPoints  (4)

(RefLink[ListContourPlot, paclet:ref/ListContourPlot]) normally uses all of the points in the dataset:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}],Mesh->All]

data=Table[{x=RandomReal[Pi],y=RandomReal[Pi],Sin[x^2+y]},{500}];

ListContourPlot[data,Mesh->All]

Limit the number of points used in each direction:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}],MaxPlotPoints->10,Mesh->All]

(RefLink[MaxPlotPoints, paclet:ref/MaxPlotPoints]) imposes a regular grid on irregular data:

data=Table[{x=RandomReal[Pi],y=RandomReal[Pi],Sin[x^2+y]},{500}];

ListContourPlot[data,MaxPlotPoints->10,Mesh->All]

The grid does not extend beyond the convex hull of the original data:

data=Select[Table[{x=RandomReal[Pi],y=RandomReal[Pi],Sin[x^2+y]},{500}],Norm[#]<Pi&];

ListContourPlot[data,MaxPlotPoints->10,Mesh->All]

OpenersExampleSubsection13(Spacer1)Mesh  (2)

Show the initial and final sampling mesh:

data=Table[Sin[x+y^2],{x,-3,3,0.2},{y,-2,2,0.2}];

{ListContourPlot[data,Mesh->Full],ListContourPlot[data,Mesh->All]}

Use 5 mesh levels in each direction:

ListContourPlot[Table[Sin[x+y^2],{x,-3,3,0.2},{y,-2,2,0.2}],Mesh->5,MeshFunctions->{#1&,#2&},MeshStyle->Darker[Orange]]

OpenersExampleSubsection14(Spacer1)MeshFunctions  (2)

Use mesh lines in the x and y directions:

ListContourPlot[Table[Sin[x+y^2],{x,-3,3,0.2},{y,-2,2,0.2}],MeshFunctions->{#1&,#2&},Mesh->{5,5},MeshStyle->Black]

Use mesh levels corresponding to real and imaginary parts of a complex-valued function:

ListContourPlot[Table[Abs[Sqrt[(x+I y)^3]],{x,-3,3,0.1},{y,-3,3,0.1}],MeshFunctions->{Re[Sqrt[(#1+I#2)^3]]&,Im[Sqrt[(#1+I#2)^3]]&},Mesh->10,MeshStyle->{Blue,Red},DataRange->{{-3,3},{-3,3}},ContourLines->False,ColorFunction->GrayLevel]

OpenersExampleSubsection15(Spacer1)MeshStyle  (2)

Use red mesh lines:

ListContourPlot[Table[Sin[x+y^2],{x,-3,3,0.2},{y,-2,2,0.2}],MeshStyle->Red,Mesh->5,MeshFunctions->{#1&,#2&}]

Use red mesh lines in the x direction and dashed mesh lines in the y direction:

ListContourPlot[Table[Sin[x+y^2],{x,-3,3,0.2},{y,-2,2,0.2}],MeshStyle->{Red,Dashed},Mesh->5,MeshFunctions->{#1&,#2&}]

OpenersExampleSubsection16(Spacer1)PerformanceGoal  (2)

Generate a higher-quality plot:

data=Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}];

Timing[ListContourPlot[data,PerformanceGoal->"Quality"]]

Emphasize performance, possibly at the cost of quality:

data=Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}];

Timing[ListContourPlot[data,PerformanceGoal->"Speed"]]

OpenersExampleSubsection17(Spacer1)PlotLegends  (6)

No legend is used, by default:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}]]

Include a legend:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}],PlotLegends->Automatic]

Legends automatically use the same colors as the density plot:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}],ColorFunction->"Rainbow",PlotLegends->Automatic]

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

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}],PlotLegends->Placed[Automatic,Below]]

Use (RefLink[BarLegend, paclet:ref/BarLegend]) to customize the legend:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}],PlotLegends->Placed[BarLegend[Automatic,LegendMargins->{{0,0},{10,5}},LegendLabel->"z-value",LabelStyle->{Italic,FontFamily->"Helvetica"}],Above]]

Legends automatically select contours to label:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}],PlotLegends->Automatic]

Label all of the contours:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.02},{j,0,Pi,0.02}],PlotLegends->BarLegend[Automatic,All]]

OpenersExampleSubsection18(Spacer1)PlotRange  (3)

Automatically compute the z range:

ListContourPlot[Table[1/(x^2+y^2),{x,-2,2,0.1},{y,-2,2,0.1}]]//Quiet

Use all points to compute the range:

ListContourPlot[Table[1/(x^2+y^2),{x,-2,2,0.1},{y,-2,2,0.1}],PlotRange->All]//Quiet

Use an explicit z range to emphasize features:

data=Table[x^2-y^2,{x,-4,4,0.2},{y,-4,4,0.2}];

{ListContourPlot[data],ListContourPlot[data,PlotRange->{-2,2}]}

OpenersExampleSubsection19(Spacer1)PlotTheme  (1)

Use a monochrome theme:

ListContourPlot[Table[i^2-j^3,{i,-1.5,1.5,0.1},{j,-1.5,1.5,0.1}],PlotTheme->"Monochrome"]

Change the tone:

ListContourPlot[Table[i^2-j^3,{i,-1.5,1.5,0.1},{j,-1.5,1.5,0.1}],PlotTheme->{"Monochrome",Orange}]

Add a legend and change the contour style:

ListContourPlot[Table[i^2-j^3,{i,-1.5,1.5,0.1},{j,-1.5,1.5,0.1}],PlotTheme->{"Monochrome",Orange},PlotLegends->Automatic,ContourStyle->Blue]

OpenersExampleSubsection20(Spacer1)RegionFunction  (4)

Plot over a region in z:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}],RegionFunction->Function[{x,y,z},Abs[z]>0.5],BoundaryStyle->Red]

The region depends on (RefLink[DataRange, paclet:ref/DataRange]):

data=Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}];

ListContourPlot[data,RegionFunction->Function[{x,y,z},Norm[{x,y}]<3],BoundaryStyle->Red]

ListContourPlot[data,RegionFunction->Function[{x,y,z},Norm[{x,y}]<3],DataRange->{{0,Pi},{0,Pi}},BoundaryStyle->Red]

Regions do not have to be connected:

ListContourPlot[Table[Sin[j^2+i],{i,0,Pi,0.07},{j,0,Pi,0.07}],RegionFunction->Function[{x,y,z},0<Mod[x^2+y^2,2]<1],DataRange->{{0,Pi},{0,Pi}},BoundaryStyle->Red]

Use any logical combination of conditions:

ListContourPlot[Table[Sin[x+y^2],{x,-2,2,0.1},{y,-2,2,0.1}],RegionFunction->Function[{x,y,z},(x-1/2)^2+y^2>1&&(x+1/2)^2+y^2>1],BoundaryStyle->Red,DataRange->{{-2,2},{-2,2}}]

OpenersExampleSubsection21(Spacer1)ScalingFunctions  (9)

By default, plots have linear scales in each direction:

ListContourPlot[Table[Max[x,y],{x,0,10,.1},{y,0,10,.1}]]

Use a log scale in the y direction:

ListContourPlot[Table[Max[x,y],{x,0,10,.1},{y,0,10,.1}],ScalingFunctions->{None,"Log"}]

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

ListContourPlot[Table[Max[x,y],{x,0,10,.1},{y,0,10,.1}],ScalingFunctions->{None,"Reverse"}]

Use a reciprocal scale in the y direction:

ListContourPlot[Table[Max[x,y],{x,0,10,.1},{y,0,10,.1}],ScalingFunctions->{None,"Reciprocal"},PlotRangePadding->None]

Use different scales in the x and y directions:

ListContourPlot[Table[Max[x,y],{x,0,10,.1},{y,0,10,.1}],ScalingFunctions->{"Reverse","Log"}]

Reverse the x axis without changing the y axis:

ListContourPlot[Table[Max[x,y],{x,0,10,.1},{y,0,10,.1}],ScalingFunctions->{"Reverse",None}]

Use a scale defined by a function and its inverse:

ListContourPlot[Table[Max[x,y],{x,0,10,.1},{y,0,10,.1}],ScalingFunctions->{None,{-Log[#]&,Exp[-#]&}}]

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

ListContourPlot[Table[Max[x,y],{x,0,100,1},{y,0,100,1}],ScalingFunctions->{"Log",None},FrameTicks->{{Automatic,Automatic},{2^Range[10],Automatic}},GridLines->All]

(RefLink[PlotRange, paclet:ref/PlotRange]) is automatically scaled:

ListContourPlot[Table[x^2+y^2,{x,0,10.1},{y,0,10,.1}],ScalingFunctions->{None,"Log"},PlotRange->{Automatic,{2,5}}]

OpenersExampleSection3(Spacer1)Applications  (2)

The contours for a probability density function:

f=PDF[LogNormalDistribution[0,1],x]PDF[LogNormalDistribution[0,1],y]

ListContourPlot[Table[f,{x,0,3,.1},{y,0,3,.1}],DataRange->{{0,3},{0,3}}]//Quiet

Compare to the empirical density function:

data=BinCounts[Select[RandomReal[LogNormalDistribution[0,1],{10^5,2}],0≤#[[1]]≤3&&0≤#[[2]]≤3&],0.1,0.1];

ListContourPlot[data,DataRange->{{0,3},{0,3}},InterpolationOrder->3,PlotRange->All]

Contouring medical data:

ListContourPlot[ Reverse@Import["ExampleData/head.dcm.gz", "Data"][[1]], ColorFunction -> "ModifiedSpectral",MaxPlotPoints->100]

OpenersExampleSection4(Spacer1)Properties & Relations  (14)

(RefLink[ListContourPlot, paclet:ref/ListContourPlot]) is similar to (RefLink[ListDensityPlot, paclet:ref/ListDensityPlot]), but with bands of discrete colors:

data=Table[Sin[u+v^2],{u,0,3,.05},{v,0,3,.05}];

{ListContourPlot[data],ListDensityPlot[data]}

(RefLink[ListContourPlot, paclet:ref/ListContourPlot]) and (RefLink[ListPlot3D, paclet:ref/ListPlot3D]) view z as a function of x and y:

data1=Flatten[Table[{Cos[ϕ] Sin[θ],Sin[ϕ] Sin[θ],-Cos[θ]},{ϕ,0.,2Pi,0.4},{θ,0.,Pi,0.4}],1];

The data has only one z value for each x, y pair:

{ListContourPlot[data1],ListPlot3D[data1,Mesh->None,BoxRatios->Automatic]}

The data has two z values for each x, y pair:

data2=Flatten[Table[{Cos[ϕ] Sin[θ],Sin[ϕ] Sin[θ],Cos[θ]},{ϕ,0.,2Pi,(2Pi)/25},{θ,0.,Pi,Pi/25}],1];

{ListContourPlot[data2],ListPlot3D[data2,Mesh->None,BoxRatios->Automatic]}

Use (RefLink[ArrayPlot, paclet:ref/ArrayPlot]) for arrays of discrete data:

ArrayPlot[CellularAutomaton[30,{{1},0},50]]

Use (RefLink[MatrixPlot, paclet:ref/MatrixPlot]) for structural plots of matrices:

MatrixPlot[Import[ "ExampleData/bcsstk08.mtx.gz"]]

Use (RefLink[ReliefPlot, paclet:ref/ReliefPlot]) for matrices corresponding to medical and geographic values:

ReliefPlot[Import["http://exampledata.wolfram.com/hailey.dem.gz","Data"],ColorFunction->"Topographic", MaxPlotPoints -> 200]

Use (RefLink[ListContourPlot3D, paclet:ref/ListContourPlot3D]) to generate contour surfaces from four-dimensional data:

data=Apply[{##,Norm[{##}]}&,RandomReal[1,{10^4,3}],1];

ListContourPlot3D[data,Mesh->None]

Use (RefLink[ContourPlot, paclet:ref/ContourPlot]) for functions:

{ContourPlot[Sin[x y],{x,0,3},{y,0,3}],ListContourPlot[Table[Sin[x y],{y,0,3,0.1},{x,0,3,0.1}],DataRange->{{0,3},{0,3}}]}

Use (RefLink[ListPointPlot3D, paclet:ref/ListPointPlot3D]) to show three-dimensional points:

ListPointPlot3D[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}]]

Use (RefLink[ListDensityPlot, paclet:ref/ListDensityPlot]) to create densities from continuous data:

ListDensityPlot[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}]]

Use (RefLink[ListPlot3D, paclet:ref/ListPlot3D]) to create surfaces from continuous data:

ListPlot3D[Table[Sin[j^2+i],{i,0,Pi,0.1},{j,0,Pi,0.1}]]

Use (RefLink[ListLogPlot, paclet:ref/ListLogPlot]), (RefLink[ListLogLogPlot, paclet:ref/ListLogLogPlot]), and (RefLink[ListLogLinearPlot, paclet:ref/ListLogLinearPlot]) for logarithmic plots:

ListLogPlot[Table[Fibonacci[k],{k,0,15}],Joined->True]

Use (RefLink[ListPolarPlot, paclet:ref/ListPolarPlot]) for polar plots:

ListPolarPlot[Table[{x,Sqrt[x]},{x,0,2Pi,0.1}]]

Use (RefLink[DateListPlot, paclet:ref/DateListPlot]) to show data over time:

DateListPlot[{5,11,13,24,28,31,34,39,42,47,51,66},{2006,1},PlotStyle->PointSize[Medium]]

Use (RefLink[ParametricPlot3D, paclet:ref/ParametricPlot3D]) for three-dimensional parametric curves and surfaces:

{ParametricPlot3D[{Cos[θ],Sin[θ],Sqrt[θ]},{θ,0,6Pi}],ParametricPlot3D[{r^2 Cos[θ],r^2 Sin[θ],r Sqrt[θ]},{r,0,1},{θ,0,6Pi}]}

OpenersExampleSection5(Spacer1)Possible Issues  (2)

The appearance may depend on the source of the data:

ListContourPlot[Table[Sin[x+y^2],{x,0,3,0.1},{y,0,3,0.1}]]

ListContourPlot[Table[Sin[x+y^2],{y,0,3,0.1},{x,0,3,0.1}]]

An n×3 matrix is by default interpreted as a list of triples:

data=Partition[RandomSample[Range[9],9],3];

ListContourPlot[data,DataRange->Automatic]

Use (RefLink[DataRange, paclet:ref/DataRange])->(RefLink[All, paclet:ref/All]) to force interpretation as a matrix of z values:

ListContourPlot[data,DataRange->All]

Or provide an explicit list of data ranges to force interpretation as a matrix of z values:

ListContourPlot[data,DataRange->{{0,1},{0,1}}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ContourPlot, paclet:ref/ContourPlot])  ▪  (RefLink[ListDensityPlot, paclet:ref/ListDensityPlot])  ▪  (RefLink[ListContourPlot3D, paclet:ref/ListContourPlot3D])  ▪  (RefLink[ListSliceContourPlot3D, paclet:ref/ListSliceContourPlot3D])  ▪  (RefLink[ListInterpolation, paclet:ref/ListInterpolation])  ▪  (RefLink[ListPlot3D, paclet:ref/ListPlot3D])  ▪  (RefLink[ListSurfacePlot3D, paclet:ref/ListSurfacePlot3D])  ▪  (RefLink[ReliefPlot, paclet:ref/ReliefPlot])  ▪  (RefLink[ListStreamDensityPlot, paclet:ref/ListStreamDensityPlot])  ▪  (RefLink[GeoGraphics, paclet:ref/GeoGraphics])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Plotting Lists of Data, paclet:tutorial/PlottingListsOfData])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Data Visualization, paclet:guide/DataVisualization])}, {▪(RefLinkPlain[Scientific Data Analysis, paclet:guide/ScientificDataAnalysis])}, {▪(RefLinkPlain[Numerical Data, paclet:guide/NumericalData])}, {▪(RefLinkPlain[Statistical Visualization, paclet:guide/StatisticalVisualization])}, {▪(RefLinkPlain[Charting and Information Visualization, paclet:guide/ChartingAndInformationVisualization])}, {▪(RefLinkPlain[Financial Visualization, paclet:guide/FinancialVisualization])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/24-more-forms-of-visualization.html])(WebLink[: More Forms of Visualization, https://www.wolfram.com/language/elementary-introduction/24-more-forms-of-visualization.html])}})}})