0
$\begingroup$

I am a beginner in Mathematica, and have a ListDensityPlot and want to plot over it points from a table I have on one file. That's the code I've written:

{
data1 = Import["/home/file1.dat", "Table"]
data2 = Import["/home/file2.dat", "Table"]

asigmaH = data1[[All, {1, 2, 3}]];
aex = data2[[All, {1, 2}]];



     ListDensityPlot[asigmaH, 
      PlotRange -> {{61.5, 63.5}, {0, 1}, {0, 1000}},
      ColorFunction -> (ColorData[{"Rainbow", {0, 100}}]),
      ColorFunctionScaling -> False, ColorFunction -> colorfunc, 
      Mesh -> False,
      Epilog ->Show[ListPlot[aex,PlotStyle -> Directive[Black, PointSize[Large]]]],
      FrameLabel -> {\[ScriptA] RowBox[{"(", AU, ")"}] // 
      DisplayForm, \[ScriptE]},
      LabelStyle -> Large, PlotTheme -> {"Monochrome"},
      PlotLegends -> Range[{0, 100}]]
     }

enter image description here

What I get is only the rendered map with no points over it as can be seen from the picture above. The file1.dat is a table with two columns tab spaced. [EDITED] Here are the files: file1 https://drive.google.com/file/d/1kwuN7OQahO3Qzx5dBrLexn44v-rNCIK2/view?usp=sharing file 2 https://drive.google.com/file/d/1axK02MPJgOXz4goFfY_6WBHkvkypv4At/view?usp=sharing

How should I proceed? Thanks in advance.

Alan

$\endgroup$
  • $\begingroup$ Could you perhaps post the contents of file1.dat and file2.dat in some place like Pastebin so that others can test things out while trying to help you? $\endgroup$ – J. M.'s discontentment Apr 17 at 12:18
  • $\begingroup$ Should I add the files here on comment?Here are the file1.dat and file2.dat file2 pastebin.com/3C87u5Ns $\endgroup$ – Alan Carmo Apr 17 at 14:32
  • $\begingroup$ That's only file2, where's file1? Also, please edit your question to include these links. $\endgroup$ – J. M.'s discontentment Apr 17 at 14:37
  • $\begingroup$ Thank you for your comments. The question is already edited. $\endgroup$ – Alan Carmo Apr 17 at 14:54
1
$\begingroup$

The Epilog option requires a list of graphics primitives, not a complete graphics. To get this, either take the first part of ListPlot, or use Point directly.

Here's an illustration using the first example in ListDensityPlot documentation. First create some points:

pts = RandomReal[{1, 4}, {10, 2}];

then add them to a density plot:

Method 1: (note use of [[1]] after the ListPlot to extract the primitives)

ListDensityPlot[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 2, 1,  4}}, Epilog -> ListPlot[pts, PlotStyle -> Directive[Black, PointSize[Large]]][[1]]]

Method 2:

ListDensityPlot[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 2, 1, 4}}, Epilog -> Style[Point[pts], Directive[Black, PointSize[Large]]]]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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