감동, 마음이 움직이는 것

[Mahtematica] StreamDensityPlot 본문

Tips (Utility, Computer Language, and etc.)

[Mahtematica] StreamDensityPlot

Struggler J. 2017. 6. 20. 00:01
[Whole script]
f[m_] := RGBColor[m^alpha, m^alpha, m^alpha] 
StreamDensityPlot[{r*x - x^2/M - x*y/b/M, r*y - x*y/c/M - y^2/d/M}, {x, 0, xrange}, {y, 0, yrange},  
   ColorFunction -> f,    
   StreamPoints -> Coarse, StreamStyle -> Orange, StreamScale -> Large, 
   PlotRange -> {{0, xrange}, {0, yrange}}, 
   BaseStyle -> {FontFamily -> "Helvetica", 20}, 
   FrameLabel -> {"Abundance n", "Abundance m"},
   LabelStyle -> Directive[Black, 15], AspectRatio -> Automatic,   
   FrameTicks -> {{{0, 400, 800}, None}, {{0, 400, 800, 1200}, None}}];


[Explanation line by line]
//Define User Color Function 
f[m_] := RGBColor[m^alpha, m^alpha, m^alpha] 

StreamDensityPlot[
//Function for Coloring at Position (x,y), xrange, yrange   
{r*x - x^2/M - x*y/b/M, r*y - x*y/c/M - y^2/d/M}, {x, 0, xrange}, {y, 0, yrange},  

//Use the Color Function Defined as f
ColorFunction -> f,    

//Number of Stream Points, Color of line, and Scale of the stream
StreamPoints -> Coarse, StreamStyle -> Orange, StreamScale -> Large, 

//To Get Rid of Margin in Default Setting   
PlotRange -> {{0, xrange}, {0, yrange}}, 

//For Labelling as gnuplot style: Helvetica font, and Black color
BaseStyle -> {FontFamily -> "Helvetica", 20}, 
FrameLabel -> {"Abundance n", "Abundance m"},
LabelStyle -> Directive[Black, 15], AspectRatio -> Automatic,   

\\Ticks, {None} means no ticks at x2, and y2 axis
FrameTicks -> {{{0, 400, 800}, None}, {{0, 400, 800, 1200}, None}}];


[Example]

M = 1000; a = 1; b = 0.03; c = 0.71; d = 0.62; r = 0.5;

xrange = 1.2 r M ; yrange = .3 r M d;

plt1 = StreamDensityPlot[{r*x - x^2/M - x*y/b/M,  r*y - x*y/c/M - y^2/d/M}, {x, 0, xrange}, {y, 0, yrange}, 

   StreamStyle -> Orange, VectorScale -> Large,  ColorFunction -> "Rainbow", VectorStyle -> White, 

   StreamPoints -> Fine];

plt2 = ListPlot[{{(r M a c )/(a d - b c) (d - b), (r M b d )/( a d - b c) (a - c)}, {0, 0}, {r*M, 1}, {0, r*M*d}}, PlotStyle -> {PointSize[0.02], Yellow}, PlotRange -> {{0, xrange}, {0, yrange}}];

plt3 = Plot[{(d (c M r - x))/c, -((b M (-a r + M x))/a) }, {x, 0, 500}];

plt4 = ListLinePlot[path, PlotRange -> {{0, 600}, {0, 100}}, PlotStyle -> White];

fig = Show[plt1, plt2 , plt3, plt4, AxesLabel -> {Style[x, FontSize -> 10, Bold, Red],  Style[y, FontSize -> 10, Bold, Blue]}]