I would like to put a large round dot at (x,y)=(0,1) in front of a plot constructed with the ListContourPlot function. I have made some attempts, but it proved to be unsuccessful. This is one of them, which shows the dot, but does not exhbit the axes:

data = Table[Sin[x] + Sin[y], {x, 0, 2 Pi, 0.2}, {y, 0, 2 Pi, 0.2}];
foregroundData = {{0, 1}};
plot = ListContourPlot[data];
foregroundPlot = 
  Graphics[{PointSize[Large], Red, Point[foregroundData]}];
Show[foregroundPlot, plot]

Could you please help me how to show both the axes and the dot?


1 Answer 1

Show[plot, foregroundPlot, PlotRangeClipping -> False]

enter image description here


Show[foregroundPlot, plot, PlotRangeClipping -> False, Options[plot]]

enter image description here

Note: Default setting for the option PlotRangeClipping is True for ListContourPlot:

Options[ListContourPlot, PlotRangeClipping]
{PlotRangeClipping -> True}

You can also use PlotRange -> All in Show[...] to have the dot inside the frame:

Show[plot, foregroundPlot, PlotRange -> All]

enter image description here

  • $\begingroup$ Thank you very much for posting this answer! It helped a lot! $\endgroup$
    – TobiR
    Jul 11, 2023 at 19:39
  • 1
    $\begingroup$ @TobiR, my pleasure. Thank you for the accept. $\endgroup$
    – kglr
    Jul 11, 2023 at 19:40
  • $\begingroup$ A minor question related to this one. In my real problem, PlotRangeClipping -> False causes that the part of the plot outside the coordinate limits also appears on the figure, which I'd like to avoid. Do you have a solution which avoids plotting data outside the ranges specified? Is this problem connected to PlotRangeClipping -> False or it is induced by something else? $\endgroup$
    – TobiR
    Jul 11, 2023 at 20:01
  • $\begingroup$ See if this Q/A and the links there give what you need. $\endgroup$
    – kglr
    Jul 11, 2023 at 20:12
  • $\begingroup$ Thanks for the link. I could not apply those things, because I could not position the red dot correctly. $\endgroup$
    – TobiR
    Jul 11, 2023 at 21:47

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.