3
$\begingroup$

I am showing two figures with Show:

a = ListPlot3D[{{0, 0, 3}, {0, 1, 3}, {1, 0, 3}, {1, 1, 3}, {0.25, 
 0.5, 1}, {0.75, 0.5, 1}}];
b = ListLinePlot[{0, 4, 2, 7, 4, 9}];
c = Graphics3D[{EdgeForm[], {Texture[b], Blue, 
 Polygon[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}, 
  VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}},
Axes -> True];
Show[{c, a}]

Now, because I want the background of b to be white, I do :

d = Graphics3D[{EdgeForm[], {Texture[b], Blue, 
 Polygon[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}, 
  VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}},
Lighting -> "Neutral", Axes -> True];

But when I do

 Show[{d, a}]

the figure a also becomes white. How can I solve this problem?

Thank you.

$\endgroup$

3 Answers 3

4
$\begingroup$

To make the 2D figure retain its own colors, independently of the 3D lighting, you could add Glow to the 2D figure. This doesn't add any transparency to the image, and from the question I concluded that you're not really looking for transparency:

a = ListPlot3D[{{0, 0, 3}, {0, 1, 3}, {1, 0, 3}, {1, 1, 3}, {0.25, 
     0.5, 1}, {0.75, 0.5, 1}}];
b = ListLinePlot[{0, 4, 2, 7, 4, 9}];
c = Graphics3D[{EdgeForm[], {Glow[White], Texture[b], Blue, 
     Polygon[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}, 
      VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}},
    Axes -> True];
Show[{c, a}]

glow

$\endgroup$
1
  • $\begingroup$ Thank you very much, this works perfectly! $\endgroup$
    – Mencia
    Jun 24, 2015 at 8:30
2
$\begingroup$

What I would do is make the 2D plot background transparent:

b = ImageData@Rasterize[ListLinePlot[{0, 4, 2, 7, 4, 9}], Background -> None];

Then you don't have to have to worry about lighting:

Show[{c, a}]

Tranpsarent2D

$\endgroup$
2
  • $\begingroup$ thank you. It does the job. But there is a problem with the resolution of b. Can you increase the resolution? I tried adding Raterize->2000 but it did not work. $\endgroup$
    – Mencia
    Jun 23, 2015 at 21:33
  • $\begingroup$ You can use RasterSize -> 2000 as an option in Rasterize. But it still doesn't look that flash. Jens' solution looks better. $\endgroup$
    – wxffles
    Jun 23, 2015 at 23:55
1
$\begingroup$

Setting the lighting in a and then showing a and d in the order a first (order matters) does what I think you want in V10.1. No sure if it will work in V9, but I think it might.

a = 
  ListPlot3D[{
    {0, 0, 3}, {0, 1, 3}, {1, 0, 3}, {1, 1, 3}, {0.25, 0.5, 1}, {0.75, 0.5, 1}}, 
    PlotStyle -> White,
    Lighting -> {{"Ambient", RGBColor[1., 0.85, .25]}}]

plot-a

b = ListLinePlot[{0, 4, 2, 7, 4, 9}, PlotStyle -> {Blue, Thick}]

plot-b

d = 
  Graphics3D[{
    EdgeForm[], {Texture[b], 
    Polygon[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}, 
    VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}}];

Show[a, d,
  BoxRatios -> {1, 1, 1},
  PlotRange -> All,
  Lighting -> "Neutral"]

plot-a-d

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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