5
p1 = Plot[x^2, {x, -2, 2}, PlotStyle -> {Thick, Black}]; 
p2 = Graphics3D[{EdgeForm[Black], Texture[p1], 
 Polygon[{{-2, 0, -1}, {2, 0, -1}, {2, 4, -1}, {-2, 4, -1}}, 
 VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}], 
 Opacity[1]}, Lighting -> "Neutral", Boxed -> False];
squares = 
 Table[Graphics3D[{Opacity[.3], 
 Polygon[{{-Sqrt[y], y, 0}, {Sqrt[y], y, 0}, {Sqrt[y], y, 
 2 Sqrt[y]}, {-Sqrt[y], y, 2 Sqrt[y]}}]}, Boxed -> False], {y, 0, 4, .25}];
all = Show[Table[squares[[j]], {j, 1, 16}]];
Show[p2]
Show[p2, all]

results in this output for me:

However, for others (at least one of whom is a Mac user), indeed the p2 graphic shows up in the second result.

When I click on the cell bracket, and Save As... PDF, the result is

And finally, if I directly copy and paste the figure (rather than export), I get this:

enter image description here

I need some independent confirmation of if this a bug in the Windows 7 version of v8.0.4 and if you have any ideas for workarounds since I need a PDF version of the last figure for insertion into other docs. Thanks.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
JohnD
  • 3,301
  • 3
  • 22
  • 42

1 Answers1

7

This non-appearance of the texture is a known bug that also affects Macs. It can be fixed by providing as the Texture only the ImageData of the rasterized graphic. So you have to replace

Texture[p1]

by

Texture[ImageData@Rasterize[p1, "Image"]]

and then the texture will show up. I modified your definitions a little, in line with what I already said in this answer:

p1 = Plot[x^2, {x, -2, 2}, PlotStyle -> {Thick, Black}, 
   ImageSize -> 600];

p2 = Graphics3D[{EdgeForm[Black], 
    Texture[ImageData[
      Rasterize[p1, "Image", ImageResolution -> 120]]], Polygon[
     {{-2, 0, -1}, {2, 0, -1}, {2, 4, -1}, {-2, 4, -1}}, 
     VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}
     ],
    Opacity[1]},
   Lighting -> "Neutral",
   Boxed -> False,
   ImageSize -> 600
   ];

squares = 
  Graphics3D[
   Table[{Opacity[.3], 
     Polygon[{{-Sqrt[y], y, 0}, {Sqrt[y], y, 0}, {Sqrt[y], y, 
        2 Sqrt[y]}, {-Sqrt[y], y, 2 Sqrt[y]}}]}, {y, 0, 4, .25}], 
   Boxed -> False, ImageSize -> 600];

all = Graphics3D[{p2[[1]], squares[[1]]},
  Lighting -> "Neutral",
  Boxed -> False,
  ImageSize -> 600]

Note I added ImageResolution to the Rasterize command to try and make the resulting texture look a little smoother.

The resulting file after Export["file.pdf", all] is here:

pdf

Edit

A reference for this bug fix is this MathGroup discussion.

Jens
  • 97,245
  • 7
  • 213
  • 499
  • This does produce the desired result in the exported PDF, but the output of the code in Mathematica still doesn't show the bottom Texture graphic for me. (However, my main concern was the PDF.) – JohnD Jul 03 '12 at 14:52