I have an image that I want to place in the background of a plot and stretch it to cover the entire plot area. However, the aspect ratio of the image does not match the aspect ratio of the plot, and Inset
refuses to stretch the image.
image = Image@Map[ColorData["SunsetColors"],
Table[(y - x^2 + 1)/2, {y, Reverse@Range[0, 1, 0.02]}, {x, 0, 1, 0.01}], {2}];
ContourPlot[y - x^2, {x, 0, 1}, {y, 0, 1}, ContourShading -> None,
Prolog -> Inset[image, {0, 0}, {0, 0}, {1, 1}]]
The Inset
documentation states:
If size is given as $\{w,h\}$, then any object $\mathit{obj}$ whose aspect ratio is not fixed will be horizontally or vertically stretched so as to fit exactly in a $w\times h$ rectangle.
If $\mathit{obj}$ is an object with fixed aspect ratio, then blank space will be left equally on both sides if there is a direction where the object would have to be stretched in order to fit exactly.
Evidently Inset
thinks the image is an object with fixed aspect ratio. How can I get around this?