1
$\begingroup$

I want to illustrate a line on a ListContourPlot. In particular, I have the following plot:

ListContourPlot[data1, PlotLegends -> Automatic, AxesLabel -> {"x", "y"}, FrameLabel -> {"x", "y"}, Contours -> 50, ColorFunction -> (If[# <= 0, Darker[Black, Abs[#]], Hue[#]] &), ColorFunctionScaling -> True, PlotRange -> All] 

where data1 is a nest list of values (too large to attach here, but consider the example: { …, {0.5610, 0.05244, 0.1015}, {0.5610, 0.05344, 0.09612}, {0.5610, 0.05444, 0.09072}, {0.5610, 0.05549, 0.08536}, {0.5610, 0.05644, 0.08004}, {0.5610, 0.05744, 0.07476}, … }).

I have a separate list data2, which traces a line (again too large to attach). How can I illustrate the line corresponding to data2 on top of the ContourPlot corresponding to data1? I would like the line to correspond to the same color range specified for the contour plot, but made thicker to distinguish it as data from the line data2.

EDIT

Note that the data lists have the structure: {{x1,y1,z1}, {x2,y2,z2}, {x3,y3,z3}, ...} and {{x'1,y'1,z'1}, {x'2,y'2,z'2}, {x'3,y'3,z'3}, ...} for data1 and data2 respectively. A snippet is as follows:

data1 = {{0.485, 0.1023, 0}, {0.485, 0.1223, 0}, {0.505, 0.0884, 0.00575}, {0.505, 0.1084, 0}, {0.50508, 0.1284, 0}, {0.525, 0.0945, 0}, {0.525, 0.1145, 0}, {0.52508, 0.1345, 0}, {0.54508, 0.0805, 0}, {0.545, 0.1005, 0}, {0.545, 0.1205, 0}, {0.54508, 0.1405, 0}, {0.545, 0.1605, 0}} data2 = {{0.4650, 0.1162, 0}, {0.4748, 0.1095, 0}, {0.4845, 0.1027, 0}, {0.4942, 0.0959, 0}, {0.50397, 0.0892, 0.0047}, {0.5136, 0.0824, 0.0151}, {0.5234, 0.0756, 0.0292}, {0.5331, 0.0689, 0.0468}, {0.5428, 0.0621, 0.0680}, {0.5525, 0.0553, 0.0930}, {0.5622, 0.0486, 0.1220}} 

data1 is a contour plot, while data2 should be a line.

$\endgroup$
2
  • 1
    $\begingroup$ You can save your file to GoogleDrive or OneDrive etc. Create and subsequently post a public link to this file to get more concrete answers. Have you already explored Show and did it not work? $\endgroup$ Commented Sep 19, 2023 at 5:27
  • $\begingroup$ @Syed, thank you for your comment. I've added some further information on data1 and data2. $\endgroup$ Commented Sep 19, 2023 at 13:13

1 Answer 1

1
$\begingroup$

I hope I interpreted you description correctly. You have 2 ListContourPlot, one showing some surface and the other only a line. Concerning the color, as the line is a contour with a single value, it has a single color.

As you did not give some data, I create some arbitrary data:

dat = Table[i^2 + j^2, {i, 10}, {j, 10}]; line = Table[i + j, {i, 10}, {j, 10}]; 

With this:

Show[ListContourPlot[{dat}], ListContourPlot[line, Contours -> 1, ContourShading -> None, ContourStyle -> Directive[Blue, Thickness -> 0.01]]]

enter image description here

$\endgroup$
5
  • $\begingroup$ Thanks! data1 has the structure {{x1,y1,z1}, {x2,y2,z2}, {x3,y3,z3}, ...} and data2 has the structure {{x'1,y'1,z'1}, {x'2,y'2,z'2}, {x'3,y'3,z'3}, ...}. Could you give a solution that matches this structure? $\endgroup$ Commented Sep 19, 2023 at 13:01
  • $\begingroup$ I have added some example data to the original questions. $\endgroup$ Commented Sep 19, 2023 at 14:04
  • $\begingroup$ If the data points are on a equal distant grid, ListContourPlot only needs the function values. Therefore use e.g.: f1/@ data1. $\endgroup$ Commented Sep 19, 2023 at 15:54
  • $\begingroup$ If by equal distant grid you mean the x' and y' values are sampled with uniform steps, then yes that's true. Could you provide an edit to your answer to illustrate this? Although the procedure for determining the data2 list is different-would be preferred to overlay the line. $\endgroup$ Commented Sep 19, 2023 at 16:09
  • $\begingroup$ Simply put: dat=f1/data1; line= f2/@data2; $\endgroup$ Commented Sep 19, 2023 at 16:16

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.