# Getting a specific contour from ListContourPlot [closed]

How can I extract a single contour line of a ListContourPlot?

Below is a minimal example:

ListContourPlot[Table[{x=RandomReal[{-2,2}],y=RandomReal[{-2,2}],Sin[x y]},{1000}]
,Contours->6
,MeshFunctions->{#3&},Mesh->{{0.5}},MeshStyle->Directive[Opacity[1,Red],Thick]
,PlotLegends->Automatic]


I'd like to get the red contour line at z = 0.5 (as an example) of different ListContourPlots and stack them in a new coordinate grid using Show.

• Why not use the settings Contours -> {0.5}, ContourShading -> None? – J. M. is in limbo Oct 18 '18 at 15:40
• Works perfectly, thanks. Sometimes, I seem to think too complicated... – DPF Oct 18 '18 at 16:08
• @J.M.iscomputer-less can you post it as an answer, such that this can be flagged as solved by @DPF? – Gladaed Oct 19 '18 at 12:52
• @Glad, not at a computer now, and this is a question that needs a picture as part of the answer. Maybe you or the OP can write one on my behalf? – J. M. is in limbo Oct 19 '18 at 13:08
• @J.M.iscomputer-less did that, any comments? – Gladaed Oct 19 '18 at 13:28

You can use contours and contourStyles to specify thresholds and colors.

contours = {0.2, 0.5, 0.9}
contourStyles = {Red, Green, Blue}
ListContourPlot[
Table[{x = RandomReal[{-2, 2}], y = RandomReal[{-2, 2}],
Sin[x y]}, {1000}],
Contours -> contours,
ContourStyle -> contourStyles,
MeshFunctions -> {#3 &},
PlotLegends -> Automatic]


You could combine them using Show like:

plots = ListContourPlot[
Table[{x = RandomReal[{-2, 2}], y = RandomReal[{-2, 2}],
Sin[x y]}, {1000}],
Contours -> {contours[[#]]},
ContourStyle -> {contourStyles[[#]]},

• Well-done! :) ${}$ – J. M. is in limbo Oct 19 '18 at 13:30