3
$\begingroup$

Recently I needed to color streamlines with exact color (e.g. RGBColor[0.1,0.478,0.5]). The help (http://reference.wolfram.com/language/ref/StreamColorFunction.html) suggests, that this can be achieved by setting StreamColorFunction to some value ("The function specified by StreamColorFunction must return color directives such as RGBColor and Hue or named colors such as Red and Blue."), however in the examples the only option used is "hue", which produces rather fancy colored streams for me (?). I'd like to have all streams e.g. Red, or Yellow, but all of the following codes:

StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1}, StreamColorFunction -> Yellow]

StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1}, StreamColorFunction -> Red]

StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1}, StreamColorFunction -> RGBColor[0,0,0]]

produces default blue streamlines, instead of yellow, red or black (there is a slight possibility that I'm color blinded since today, but I doubt it :)). Why is the StreamColorFunction behaving this way? Is there a possibility to color streams with any color I like? Any help'd be much appreciated.

$\endgroup$

2 Answers 2

5
$\begingroup$

It's a function ...you need to specify one:

StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1},  StreamColorFunction -> (Yellow &)]

StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1},  StreamColorFunction -> (Red &)]

StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1},  StreamColorFunction -> (RGBColor[0, 0, 0] &)]

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ Sure, it works, thanks, but why? $\endgroup$
    – user16320
    Sep 10, 2014 at 1:18
  • $\begingroup$ @user16320 Because ... the option needs a function as input, not a color $\endgroup$ Sep 10, 2014 at 1:19
  • $\begingroup$ @user16320 Read the "Details" section right on the help $\endgroup$ Sep 10, 2014 at 1:20
  • $\begingroup$ ok, thank you very much. $\endgroup$
    – user16320
    Sep 10, 2014 at 1:28
1
$\begingroup$

I would simply use StreamStyle:

Grid[{StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1},
     StreamStyle -> #] & /@ {Red, Green, Blue}}]

enter image description here

$\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.