Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
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.

share|improve this question
    
I can see the p2 result with 8.0.4 on Windows 7 –  b.gatessucks Jul 2 '12 at 16:15
1  
Please only use the tag bugs if the unexpected behaviour is indeed confirmed by the community (see tag wiki). –  István Zachar Jul 2 '12 at 16:15
2  
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. –  Simon Woods Jul 2 '12 at 21:03
1  
@SimonWoods Could you check this question and confirm if you seem to have the same problem as described there? –  Sjoerd C. de Vries Jul 2 '12 at 21:49
1  
@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. –  Jens Jul 3 '12 at 5:23

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
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 3 '12 at 14:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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