4
$\begingroup$

I want to plot an arrow with a gradient of color. For example, the arrow is

Graphics3D[{Red,Arrow[{{0,0,0},{0,0,2}}]}]

Then I want the Opacity is a function of 'z' coordinate, so that Opacity is 0 at the beginning and 1 at the end of the arrow.

How to modify the code above?

$\endgroup$
1
  • $\begingroup$ See my answer for a simple gradient of two colors. I'd too would be interested to know how to apply ColorFunction to a Line/Arrow $\endgroup$
    – Sascha
    Aug 30 '16 at 14:57
3
$\begingroup$

For a simple gradient you could use Line together with Arrow since Line accepts a VertexColors-option.

Graphics3D[{Red, Thick, Arrow@Line[{{0, 0, 0}, {0, 0, 2}}, 
VertexColors -> {Directive[Red, Opacity@0], Red}]}]

image of arrow

$\endgroup$
7
  • $\begingroup$ What if I want the opacity is 0 at the start and the end, and opacity is 1 in the middle? @Sascha $\endgroup$
    – Qi Zhong
    Aug 30 '16 at 15:21
  • $\begingroup$ As stated in my answer/comment to your original post: This method only works for a simple gradient with two colors. I'd like to know that too though. $\endgroup$
    – Sascha
    Aug 30 '16 at 15:25
  • $\begingroup$ Do you know how to change the color of the arrowheads? The end of the arrow is transparent, however, the arrowhead is still red. @Sascha $\endgroup$
    – Qi Zhong
    Aug 30 '16 at 15:39
  • $\begingroup$ The first list entry (Red in my answer) determines the color of the arrow head $\endgroup$
    – Sascha
    Aug 30 '16 at 15:43
  • $\begingroup$ Graphics3D[{Directive[Red, Opacity@0], Thick, Arrow@Line[{{0, 0, 0}, {0, 0, 2}}, VertexColors -> {Red,Directive[Red, Opacity@0]}]}] It will show nothing. I want the arrowhead is transparent too. @Sascha $\endgroup$
    – Qi Zhong
    Aug 30 '16 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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