6

I'm trying to make a ContourPlot of a set of data of the kind: $(x,y,f(x,y))$

What I'd like to do is to remove the majority of the iso-line and just leave two of them, but keeping the changing of the color.

In other words I'd like to obtain something like a ListDensityPlot of my data set, but with two iso-curves marking the points $(x,y)$ having either value $0$ or $-0.0005$.

Any idea on how to do this? like for example overlapping two different graphs on each other or extracting the iso-curve interpolant from the contour plot and plug it into the density plot? these are just some ideas...

kglr
  • 394,356
  • 18
  • 477
  • 896
SSC Napoli
  • 415
  • 2
  • 11
  • "ContourStyle → ${g_1, g_2, \ldots}$ specifies that successive directives $g_i$ should be used to draw successive contours." So, for example, Contours -> {0, 0.1, 0.2, 0.5}, ContourStyle -> {Black, None, None, Black}. –  Dec 31 '14 at 18:11
  • You could also Show a ListContourPlot with just the contours you want (and ContourShading -> None) on top of a ListDensityPlot. –  Dec 31 '14 at 18:14
  • this seems a very nice idea! – SSC Napoli Dec 31 '14 at 18:17

1 Answers1

13
data = Table[Sin[i + j^2], {i, 0, 3, 0.05}, {j, 0, 3, 0.05}];

ListContourPlot[data, ColorFunction -> "Rainbow", 
 Contours -> {{0, {Thick, Black}}, {-.5, {Thick, Dashed, Black}}, 
               Sequence @@ ({#, None} & /@ Range[Min@data, Max@data, .0025])}]

enter image description here

You can also use the desired contours as Epilog with ListDensityPlot:

lcp = ListContourPlot[data, ContourShading -> None,
   Contours -> {{0, {Thick, Black}}, {-.5, {Thick, Dashed, Black}}}];
ListDensityPlot[data, ColorFunction -> "Rainbow", Epilog -> lcp[[1]]]

enter image description here

Or, to use default contour styles, use Contours -> {0, -.5} in lcp to get

ListDensityPlot[data, ColorFunction -> "Rainbow", Epilog -> lcp[[1]]]

enter image description here

Update: You can also use Mesh and MeshFunctions with ListDensityPlot:

ListDensityPlot[data, ColorFunction -> "Rainbow", MeshFunctions -> {#3 &},  Mesh -> {{0., -.5}}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896