0
$\begingroup$

I want to combine a ListPlot with a MatrixPlot.

I have a set of points to be used with a ListPlot. At the same time, I want to show a kind of heat map to show the intensity of their locations in a grid style map.

So, for example I have the data points:

data = {{1,2},{3,4},{5,6}}

where the maximum and minimum of both x and y values are 0 and 10, respectively. Now I want to show that same points in a heat map of a 4x4 grid:

MatrixPlot[{{0, 1, 1, 0}, {0, 1, 1, 0}, {0, 1, 1, 0}, {0, 1, 1, 0}}]

where the matrix element (4,0) (lower left corner) corresponds to the (0,0) and the element (0,4) (upper right corner) corresponds to the (10,10) position.

Any idea on how shall I combine them? I'm aware of this answer but I confess I didn't understand it fully. But I suspect it does not fit to my case.

$\endgroup$
2
  • $\begingroup$ Maybe ArrayPlot ? $\endgroup$ Commented Oct 23, 2020 at 14:55
  • $\begingroup$ I think the problem is the same. Because the problem here is the combination. I want to show the heat map and on top of it the data that would go to ListPlot. $\endgroup$
    – Miguel
    Commented Oct 23, 2020 at 15:01

1 Answer 1

2
$\begingroup$

Something like this?

Show[{MatrixPlot[{{0, 1, 1, 0}, {0, 1, 1, 0}, {0, 1, 1, 0}, {0, 1, 1, 
     0}}, DataRange -> {{0, 10}, {0, 10}}, PlotTheme -> "Detailed"]
  , Graphics[{PointSize[0.03], Point[{{1, 2}, {3, 4}, {5, 6}}]}]}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks! Thanks exactly what I was looking for. $\endgroup$
    – Miguel
    Commented Oct 23, 2020 at 15:27

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.