5
$\begingroup$
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.

$\endgroup$
19
  • $\begingroup$ I can see the p2 result with 8.0.4 on Windows 7 $\endgroup$ Commented Jul 2, 2012 at 16:15
  • 1
    $\begingroup$ Please only use the tag bugs if the unexpected behaviour is indeed confirmed by the community (see tag wiki). $\endgroup$ Commented Jul 2, 2012 at 16:15
  • 2
    $\begingroup$ I can confirm I get the same problem with 8.0.4 on Windows 7. There seems to be a general problem with opacity and textures in 3D graphics - if I go to the documentation for Texture neither of the examples in the Generalizations & Extensions section work. $\endgroup$ Commented Jul 2, 2012 at 21:03
  • 1
    $\begingroup$ @SimonWoods Could you check this question and confirm if you seem to have the same problem as described there? $\endgroup$ Commented Jul 2, 2012 at 21:49
  • 1
    $\begingroup$ @IstvánZachar It is indeed a bug, confirmed by John Fultz, see the link at the end of my posted answer. So I've taken the liberty of adding the bug tag again. $\endgroup$ Commented Jul 3, 2012 at 5:23

1 Answer 1

7
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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.) $\endgroup$ Commented Jul 3, 2012 at 14:52

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.