3
$\begingroup$

I need to color this vector field. I want the vectors that have negative z component to be colored different that those ones with positive z component. This is the vector field:

table = Import["http://pastebin.com/raw/rjM2i5Jt", "Table", "IgnoreEmptyLines" -> True];

X = table[[;; , ;; 3]];
V = table[[;; , 4 ;; 6]];

g = Graphics3D[{[email protected], Arrow@Transpose[{X, X + .07 Normalize /@ V}]}, 
           BoxRatios -> {1, 1, 1}, PlotRange -> All, ViewPoint -> {1, 1, 1}, 
           ViewVertical -> {0, 1, 0}, Boxed -> False
]
$\endgroup$
0

1 Answer 1

4
$\begingroup$

Maybe

Graphics3D[{[email protected], {If[Subtract@@#[[;;,3]] <= 0, Red, Blue], 
     Arrow[#]}& /@ Transpose[{X, X + .07 Normalize /@ V}]}, 
 BoxRatios -> {1, 1, 1}, PlotRange -> All, ViewPoint -> {1, 1, 1}, 
 ViewVertical -> {0, 1, 0}, Boxed -> False]

Mathematica graphics

$\endgroup$
6
  • $\begingroup$ Thank you, now i would like to do the same in a 2d vector field. I graphic the cutting planes with these lines. $\endgroup$ Commented Oct 11, 2016 at 21:12
  • $\begingroup$ table = Import["pastebin.com/raw/rjM2i5Jt", "Table", "IgnoreEmptyLines" -> True]; X = table[[;; , ;; 2]]; V = table[[;; , 4 ;; 5]]; Graphics [{[email protected], Arrow@Transpose[{X, X + .02 Normalize /@ V}]}] I would like to the same as before. Color the vectors to differentiate the ones that have postive z component from the others. Take account that here the x component is not in the graphic $\endgroup$ Commented Oct 11, 2016 at 21:17
  • $\begingroup$ z component*... $\endgroup$ Commented Oct 11, 2016 at 21:18
  • 1
    $\begingroup$ @Franco, does this give what you need: Graphics[{[email protected], {If[Subtract @@ #[[;; , 2]] <= 0, Red, Blue], Arrow[#]} & /@ Transpose[{X, X + .07 Normalize /@ V}]}]? $\endgroup$
    – kglr
    Commented Oct 11, 2016 at 21:36
  • $\begingroup$ Thank you again, you are solving all my problems! I will make the last question. Could i color the arrow with a gradient? In other words, color the arrows that have greater z component darker than the rest and keeping the two colors (negative and positives values). $\endgroup$ Commented Oct 11, 2016 at 22:00

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.