3
$\begingroup$

I'm trying to put a background image in a graph I've made but I can't figure out how to resize it so it fits the whole background, rather than just the section. The code I have so far is

combinedPlot = Show[linDataPlot, linFitPlot, errorplot, linDataPlot2,
PlotRange -> {{0.8, 2.2}, {40, 280}}, AspectRatio -> 1, Prolog -> Inset[dog]]

which shows

enter image description here

Ideally the image would reach to the frame of the graph. I think I just need to change something in the "Prolog" area of the code in order to get it to scale? And also change the "PlotRange" so it's the same ratio as the image.

However, I tried to do this with the "Raster" command:

combinedPlot = Show[linDataPlot, linFitPlot, errorplot, linDataPlot2,
PlotRange -> {{0.8, 2.2}, {40, 280}}, AspectRatio -> 1,
Prolog -> Raster[Show[dog][[1, 1]], {Scaled[{0, 0}], Scaled[{1, 1}]}]]

But for some reason the image goes really weird and looks like this:

enter image description here

Someone please help me <3

$\endgroup$
  • 1
    $\begingroup$ I don't know what dog is in your example, but look up what data Raster needs (a 2D array of numbers or of RGB triplets). $\endgroup$ – Szabolcs Aug 9 '18 at 8:01
3
$\begingroup$
Plot[Sin[x], {x, 0, 10}, 
 Axes -> False, Frame -> True,
 PlotStyle -> Orange,
 Prolog -> {Raster[
    ImageData[ExampleData[{"TestImage", "Boat"}], DataReversed -> True], 
    {Scaled[{0, 0}], Scaled[{1, 1}]}
 ]}
]

enter image description here

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.