4
$\begingroup$

enter image description here

I have drawn a contour plot like attached in the figure. Now, what I want is points along with the contour lines. For example: I have a data set like:

3.34 4.74 0.0024
3.34 4.76 0.0023
...  ...  ....

I need the points (3.34, 4.74), (3.34, 4.76) etc.. on the curve.

My code for this curve is:

abc = Import[
  "/home/users/chakrtdm/Desktop/test_25_alpha/ratio-a-b.dat", 
  "Table"]
ListContourPlot[abc, Contours -> 20, AspectRatio -> Automatic, 
 PlotRange -> {{3.24, 3.38}, {4.70, 4.84}, {0.01, 0.001}}, 
 ContourLabels -> All, 
 TextStyle -> {FontFamily -> "Helvetica", FontSize -> 11, 
   FontWeight -> Bold}, FrameLabel -> {"a", "b"}, Background -> White,
  LabelStyle -> Directive[Black, Bold]]

Please suggest me how can I improve my code to get the points in the contour lines. Thanks!

$\endgroup$
3
  • $\begingroup$ You could make a separate plot with the points only and then use Show. $\endgroup$ Oct 10, 2014 at 10:37
  • $\begingroup$ @b.gatessucks:Could you please help me by writing the code? I mean I didn't get that where should I place 'show' command? I am quite new, so apology for not understanding your answer properly. $\endgroup$ Oct 10, 2014 at 11:33
  • $\begingroup$ If you call p1=ListContourPlot[...] and p2=ListPlot[the points you want] then you can just do Show[p1, p2]. $\endgroup$ Oct 10, 2014 at 11:37

3 Answers 3

4
$\begingroup$
data = Table[
  Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]; ListContourPlot[data,
  Epilog -> {PointSize[Large], Red, Point[{{5, 15}, {10, 5}}]}]

enter image description here

$\endgroup$
7
$\begingroup$

Inspired by @eldo's ContourLabels, a variation that gives color-coded points for labels:

ListContourPlot[RandomReal[1, {10, 10}], InterpolationOrder -> 3,
 PlotLegends -> Automatic, Contours -> 10,
 ContourLabels -> (Tooltip[Graphics[{PointSize[.02], Hue[#3], Point[{#, #2}]}][[1]],
   Column[{Row@{"{x, y} = {", #, " , ", #2, "}"}, Row@{"z = ", #3}}, Alignment -> Center]] &)]

enter image description here

$\endgroup$
4
$\begingroup$
Framed[ContourPlot[Sin[x y], {x, 0, 2}, {y, 0, 2},
  Contours -> Join[Range[0, 0.9, 0.1], Range[0.91, 1, 0.01]],
  Frame -> {{True, False}, {True, False}},
  ColorFunction -> "Pastel",
  ContourStyle -> 
   Join[Table[Directive[Brown, Thick], {10}], Table[Directive[Dashed, Thin], {9}]],
  ContourLabels -> Function[{x, y, z}, Text[Framed[z], {x, y}, Background -> White]],
  ImageSize -> 600],
 FrameMargins -> 20]

enter image description here

$\endgroup$

Your Answer

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

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