Re: Using a jpg picture for a 2D plot background

*To*: mathgroup at smc.vnet.net*Subject*: [mg99005] Re: Using a jpg picture for a 2D plot background*From*: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>*Date*: Fri, 24 Apr 2009 03:44:03 -0400 (EDT)*References*: <gspgk7$nro$1@smc.vnet.net>

In 7 this could be done easily with ImageCompose, but since you've got 6 this is less trivial. One approach would be: bg = ExampleData[{"TestImage", "Peppers"}] pl = Plot[Sin[x], {x, -\[Pi], \[Pi]}]; t = RescalingTransform[{{1, 512}, {1, 512}}, {{-\[Pi], \[Pi]}, {-1, 1}}]; bg2 = GeometricTransformation[bg[[1]], t] // Graphics; Show[bg2, pl, AspectRatio -> 1, Frame -> True, BaseStyle -> {Thickness[0.02]}] There is a difference between imported pictures in 6 and 7. Whereas in 6 they're Graphics in 7 they're an Image. To have this example work in 7 one line should be different: bg2 = GeometricTransformation[Rasterize[bg][[1]], t] // Graphics; The 512 in the above code is the size of the image (both vertical and horizontal). In 7 you could use ImageDimensions to get this information. In 6 this can be gotten using either bg[[3]] or AbsoluteOptions[bg, PlotRange] Use the correct AspectRatio for the picture, otherwise it'll look distorted. Hope this helps. Cheers -- Sjoerd On Apr 23, 12:41 pm, Bill <WDWNORW... at aol.com> wrote: > Hi: > > I would like to use a jpg picture as a background for a 2D plot in Mathem= atica 6.0.1, on a PC using Win XP. > I'm not sure if this can be done. If this can be done, can someone please= give me the code to do this? > > Thanks, > > WDW