# Color a mesh using ListDensityPlot

I have a list of data and I plot using ListDensityPlot:

lista2 = Drop[
sist.dat"], 1];

contorno =
Table[{lista2[[i, 1]], lista2[[i, 2]], lista2[[i, 4]]}, {i, 1,
Length[lista2]}];

sol = ListDensityPlot[contorno,
FrameLabel -> {"\!$$\*SubscriptBox[SuperscriptBox[\(y$$, $$*$$], \
$$d$$]\)",
"\!$$\*SubscriptBox[SuperscriptBox[\(y$$, $$*$$], $$inf$$]\)"},
RotateLabel -> False, FrameStyle -> FontSize -> 14, Mesh -> 25,
MeshStyle -> Opacity[0.5]]


Data file:

https://www.dropbox.com/s/s8r4bqbavz6exvt/loop_sol_sist.dat?dl=0

The result:

Is there a way to color the mesh just in the region where is not blue (the blue region is the value of data which is zero)?

Something like that:

• Is there a way we can access your data to make the plot ourselves? – Chip Hurst Jun 1 '18 at 15:13
• How can I send you the data file? – Mateus Jun 1 '18 at 15:18
• I edited the question with a link to download the data. – Mateus Jun 1 '18 at 15:29

You can use a second ListDensityPlot with option RegionFunction ->(#3 > 0 &) to show only the region of interest and combine the two plots using Show:

contorno = lista2[[All, {1, 2, 4}]];
Show[ListDensityPlot[contorno],
ListDensityPlot[contorno, RegionFunction -> (#3 > 0 &), Mesh -> 24, MeshStyle -> Red]]


With this method you can restrict the mesh lines to arbitrary regions. For example, replace (#3 > 0& above with (Sin[#] + Cos[#2] <= .2 && # #2 <= 10 &) to get

 data = Table[Sin[x] Cos[y], {y, -Pi, Pi, Pi/64}, {x, -Pi, Pi, Pi/64}];
Show[ ListDensityPlot[data], ListDensityPlot[data, Mesh -> 24,
MeshStyle -> Red, RegionFunction ->(-2/4 < #3 < 1/4 ||#3>3/4&)]]


• What represents #,#1 and #2? – Mateus Jun 1 '18 at 15:36
• @Mateus, # (which is same as #1) refer to horizontal coordinates (x coordinate) and #2 to the vertical coordinate. ConditionalExpression[#1, # + #2 <= 10] & is the same as Function[{x,y}, ConditionalExpression[x, x+y<=10]]. – kglr Jun 1 '18 at 16:02