6
$\begingroup$

I have a vector field, Pdt1 I am trying to use as the texture for a ParametricPlot3D plot.

When I plot the vector field with the code

VF1 = StreamPlot[Pdt1[u, v], {u, -a, a}, {v, -a, a}, 
  StreamStyle -> {Red, Thick}, StreamColorFunction -> None, 
  Frame -> None, ImageSize -> Large]

It returns the image

enter image description here

as expected. All well and good. When I pass this plot as a texture to ParametricPlot3D as done with the code

Show[
 ParametricPlot3D[{x[u, v], y[u, v], z[u, v]}, {u, -a, a}, {v, -a, a},
   PlotStyle -> {Texture[VF1]},
  PlotRange -> Full, Boxed -> False, Axes -> False, 
  ImageSize -> Large
  ]
 ]

What is returned is the plot but without the red or thick styling which was given in the definition of VF1;

enter image description here

How to I get the styling of VF1 to carry over to the parametric plot?

$\endgroup$
4
  • 1
    $\begingroup$ An MWE would be helpful. $\endgroup$
    – Michael E2
    Aug 1, 2023 at 15:17
  • $\begingroup$ I'd suggest PlotRangePadding -> None, too. $\endgroup$
    – Michael E2
    Aug 1, 2023 at 15:52
  • $\begingroup$ I think it's a bug. Please report it to WRI. $\endgroup$
    – Michael E2
    Aug 1, 2023 at 16:06
  • $\begingroup$ Bug consensus, anyone? $\endgroup$
    – Michael E2
    Aug 1, 2023 at 21:04

2 Answers 2

4
$\begingroup$

Convert the StreamPlot to an Image:

 a = 1;
 fun = -v + u - u^2;

VF1 =
 StreamPlot[{u, fun}, {u, -a, a}, {v, -a, a},
   StreamStyle -> {Red, Thick},
   StreamColorFunction -> None,
   Frame -> None] // Image

enter image description here

Plot3D[fun, {v, -a, a}, {u, -a, a}, PlotStyle -> Texture[VF1], 
 Lighting -> "Neutral"]

enter image description here

$\endgroup$
4
$\begingroup$

Summary: When graphics t contains Directive[] for styling, as in the case of the OP's StreamPlot, use

PlotStyle -> Texture[t /. Directive -> Sequence]

to apply t as a texture. This prevents the internal processing, Texture[t] /. Directive -> List, which wraps the directives in their own list and prevents them from being applied to the graphic primitives in t as originally intended. I consider this a bug.


Original answer:

ParametricPlot3D[..., 
  PlotStyle -> {Texture["vf1"]},
  ...] /. "vf1" -> vf1

enter image description here

Probably a bug....(The default PlotStyle color is applied to the Texture[] graphics, which cannot be overridden by PlotStyle, AFAICT, which is being used to apply the graphics. Catch-22?)


Another workaround:

ParametricPlot3D[...,
  PlotStyle -> Texture[Hold@vf1], 
  ] // ReleaseHold

And another (prevents the refactoring of the graphics):

ParametricPlot3D[..., 
 PlotStyle -> Texture[vf1 /. Directive -> Sequence]
 ]

And the bug seems to be that Texture[..] /. Directive -> List is executed by ParametricPlot3D, which imprisons the graphics directives in a list. So the default style, which is applied automatically at the beginning of graphics takes over.

$\endgroup$

Your Answer

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

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