4
$\begingroup$

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

lista2 = Drop[
   Import["/home/mateus/LaminarSeparationBubble/RD/Dados/loop_sol_\
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:

enter image description here

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:

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ Is there a way we can access your data to make the plot ourselves? $\endgroup$
    – Greg Hurst
    Commented Jun 1, 2018 at 15:13
  • $\begingroup$ How can I send you the data file? $\endgroup$
    – Mateus
    Commented Jun 1, 2018 at 15:18
  • 1
    $\begingroup$ I edited the question with a link to download the data. $\endgroup$
    – Mateus
    Commented Jun 1, 2018 at 15:29

1 Answer 1

6
$\begingroup$

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]]

enter image description here

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

enter image description here

 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&)]]

enter image description here

$\endgroup$
2
  • $\begingroup$ What represents #,#1 and #2? $\endgroup$
    – Mateus
    Commented Jun 1, 2018 at 15:36
  • $\begingroup$ @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]]. $\endgroup$
    – kglr
    Commented Jun 1, 2018 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.