2
$\begingroup$

Bug introduced in 14.0 and fixed in 14.1

Switching to Version 14.0 (Linux), I noticed that Directive behaves unexpectedly when used inside ColorFunction for 3D Graphics. I wasn't able to find any further information on it, and I didn't want to assume anything, but it seems like a bug to me.

Compare:

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
 ColorFunction->Function[{x,y,f},Blue], Mesh -> None]

Expected Result

with

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
 ColorFunction->Function[{x,y,f},Directive[Blue]], Mesh -> None]

Unexpected Result

This doesn't happen in 13.0 nor 11.3. (More useful examples like Directive[Blue,Opacity[0.5]] etc. are of course also affected.)

All 3D plots I tried are affected, while 2D Plot seems to work. On the other hand,

Graphics3D[{Directive[Blue,Opacity[0.5]],Sphere[]}]

also works as expected.

Edit: The same effect results when using List instead of Directive. This for example means that Hue[0.5,1,1,0.5] works, but {Hue[0.5],Opacity[0.5]}, does not, even though the documentation says the two are equivalent.

Edit2: Note that this problem doesn't depend on using the arguments to ColorFunction, which is why the example simply uses Blue. Of course, for real applications of ColorFunction, the function would not be constant, meaning that PlotStyle doesn't help.

$\endgroup$
3
  • 1
    $\begingroup$ That is a bug. One workaround would be to use PlotStyle -> Directive[...] $\endgroup$
    – Jason B.
    Commented Jul 16 at 15:14
  • 1
    $\begingroup$ I see the same using 14.0 on Windows 10. $\endgroup$ Commented Jul 16 at 16:44
  • $\begingroup$ @JasonB. Thanks for confirming that it is indeed a bug. PlotStyle would work for the very simplified example here, but for the real application, I need the ColorFunction arguments. @Lexington1776 Good to know, thanks. $\endgroup$
    – ZehDeckel
    Commented Jul 17 at 10:13

1 Answer 1

0
$\begingroup$

This is a workaround to the effect you wanted:

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
ColorFunction -> Function[{x, y, z}, RGBColor[0, 0, z]], 
Mesh -> None]

enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ I don't think this is a workaround. Note that using Blue works as expected, but the OP wants to combine several graphics directives using Directive. $\endgroup$
    – Domen
    Commented Jul 16 at 16:55
  • $\begingroup$ Yes, @Domen is right, this does not really help since it does not combine graphics directives. I just left out the use of any of the ColorFunction arguments for simplicity. $\endgroup$
    – ZehDeckel
    Commented Jul 17 at 10:16

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.