I would like to overlay ListPlot
on ArrayPlot
. I have explored a number of posts, but I did not manage to achieve the desired outcome. Hence, the reason for the post. Following is a visual representation of what I want to achieve.
- Set custom axes;
- Align
ArrayPlot
toListPlot
axes; - Plot points with labels;
Here is the grid I would like to overlay...
colors = RGBColor /@ {"#c7e8ac","#ffeca9","#ff8f80"}
grid = {
{Yellow,Yellow, Red, Red, Red},
{Green, Yellow, Yellow, Red, Red},
{Green, Yellow, Yellow, Yellow, Red},
{Green, Green, Yellow, Yellow, Yellow},
{Green, Green, Green, Green, Yellow}
} /.{
Green-> colors[[1]]
, Yellow-> colors[[2]]
, Red-> colors[[3]]
};
ArrayPlot[
grid
, Mesh -> True
, Axes -> True
]
and the data would be generated in the following way...
Outer[{#2, #1, #1*#2} &, Range[0.01, 1, .01], Subdivide[1000, 20000000, 1000]] // Flatten[#, 1] &;
I have tried to implement a solution using Epilog
and Inset
. However, the results are suboptimal...
The code used for the above...
ListPlot[
{{5000, 0.05}}
, PlotRange -> {{0, 10^6}, {0, 1}}
Epilog -> Inset[
ArrayPlot[
grid
, Mesh -> True
]
, Scaled[{0.02, 0.02}]
, Scaled[{0, 0}]
, Scaled[1]
]
]
ListPlot[{{{5000, 0.05}}, {{500000, 0.7}}}, PlotLabels -> {"Label 1", "Label 2"}, PlotStyle -> Directive[Black, PointSize[Large]], PlotRange -> {{0, 10^6}, {0, 1}}, Prolog -> Inset[ArrayPlot[grid, Mesh -> True, PlotRangePadding -> None], Scaled[{0, 0}], Scaled[{0, 0}], Scaled[1]], AspectRatio -> 1]
give anything close to what you need? $\endgroup$