# How to combine ListLogLogPlot and MatrixPlot?

partida 07/16/2018. 1 answers, 103 views

Let's construct some data

data = Exp@Sort@RandomReal[10, 100];
col = Transpose@MapIndexed[Exp[First@#2/20] + #1 &, RandomReal[10, {100, 99}]];

The data and col look like this

g1 = ListLogLogPlot[data, Joined -> True, AspectRatio -> 1/2,
ImageSize -> 300]
g2 = MatrixPlot[col, AspectRatio -> 1/2, ImageSize -> 300]

I want g2 as background in g1, Show[g1,g2] can't be done.

Maybe transfer Graphics to Image and using ImageTransformation to make the g2 have a logarithmic x-axis, but I'm not familiar to Image Processing

kglr 07/16/2018.

One possible approach is to use the MatrixPlot output as Texture in a Polygon with ImageScaled coordinates (so that its size stretches to the size of the image it sits in) and use the resulting stretchable graphics primitive as Prolog in ListLogLogPlot:

mp = MatrixPlot[col, AspectRatio -> 1/2, ImageSize -> 300, ImagePadding -> 0,
DataReversed -> True, Frame -> False];
bg = {Texture[mp], Polygon[{ImageScaled /@ {{0, 0}, {1, 0}, {1, 1}, {0, 1}}},
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]};
ListLogLogPlot[data, Joined -> True, AspectRatio -> 1/2,
ImageSize -> 300, PlotRangeClipping -> True, Prolog -> bg]

An alternative approach is to use the option DataRange in MatrixPlot:

mp2 = MatrixPlot[col, AspectRatio -> 1/2, ImageSize -> 300,
DataRange -> {{0, 5}, {0, 10}}];
ListLogLogPlot[data, Joined -> True, AspectRatio -> 1/2,
ImageSize -> 300,  Prolog -> mp2[[1]]]