Plot vectors as sums of vectors along the axes - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-09-21T20:28:19Z https://mathematica.stackexchange.com/feeds/question/200167 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/200167 3 Plot vectors as sums of vectors along the axes Relayy ekko https://mathematica.stackexchange.com/users/66076 2019-06-11T21:46:32Z 2019-06-12T03:37:00Z <p>in a phase diagram appear vectors that go in different directions. When graphing with the "streamplot" or "vectorplot" command, only the arrows appear showing how they move away from or closer to balance. Well, I would like to know how to divide a vector into two arrows that indicate how it grows on each axis "x" and "y". (i put in red that i need). Thanks :D</p> <p><a href="https://i.stack.imgur.com/MXygH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MXygH.jpg" alt="enter image description here"></a></p> <pre><code>Show[Plot[{(8 + x)/4, 1/2 (-3 - x)}, {x, -10, 10}], StreamPlot[{-x + 4 y - 8, x + 2 y + 3}, {x, -10, 10}, {y, -6, 6}, StreamStyle -&gt; LightCyan, VectorPoints -&gt; {{-10, 2}, {-5, 4}, {-5, -4}, {6, -3}}, VectorScale -&gt; .15]] </code></pre> https://mathematica.stackexchange.com/questions/200167/-/200170#200170 5 Answer by chuy for Plot vectors as sums of vectors along the axes chuy https://mathematica.stackexchange.com/users/237 2019-06-11T22:11:57Z 2019-06-11T22:11:57Z <p>You could use the <a href="https://reference.wolfram.com/language/ref/Projection.html" rel="noreferrer"><code>Projection</code></a> function here to good use. First make the <a href="https://reference.wolfram.com/language/ref/StreamPlot.html" rel="noreferrer"><code>StreamPlot</code></a>:</p> <pre><code>sp = Show[Plot[{(8 + x)/4, 1/2 (-3 - x)}, {x, -10, 10}], StreamPlot[{-x + 4 y - 8, x + 2 y + 3}, {x, -10, 10}, {y, -6, 6}, StreamStyle -&gt; LightCyan, VectorPoints -&gt; {{-10, 2}, {-5, 4}, {-5, -4}, {6, -3}}, VectorScale -&gt; .15, VectorMarkers -&gt; Placed["Arrow", "Start"]]] </code></pre> <p><img src="https://i.stack.imgur.com/wbsch.png" alt="Mathematica graphics"></p> <p>Then make the projections:</p> <pre><code>vp = VectorPlot[{Projection[{-x + 4 y - 8, x + 2 y + 3}, {1, 0}], Projection[{-x + 4 y - 8, x + 2 y + 3}, {0, 1}]}, {x, -10, 10}, {y, -6, 6}, VectorStyle -&gt; Red, VectorPoints -&gt; {{-10, 2}, {-5, 4}, {-5, -4}, {6, -3}}, VectorScale -&gt; .15, VectorMarkers -&gt; Placed["Arrow", "Start"]] </code></pre> <p><img src="https://i.stack.imgur.com/nNVxY.png" alt="Mathematica graphics"></p> <p>Of course you can style the vectors as you please. Then combine:</p> <pre><code>Show[sp, vp, PlotRange -&gt; All] </code></pre> <p><img src="https://i.stack.imgur.com/e9TGH.png" alt="Mathematica graphics"></p> https://mathematica.stackexchange.com/questions/200167/-/200171#200171 3 Answer by LouisB for Plot vectors as sums of vectors along the axes LouisB https://mathematica.stackexchange.com/users/22158 2019-06-11T23:36:37Z 2019-06-11T23:36:37Z <p>Using <code>VectorPlot</code>:</p> <pre><code>{f1, f2} = {(8 + x)/4, 1/2 (-3 - x)}; {gx, gy} = {-x + 4 y - 8, x + 2 y + 3}; Show[ Plot[{f1, f2}, {x, -10, 10}], StreamPlot[{gx, gy}, {x, -10, 10}, {y, -6, 6}, StreamStyle -&gt; Cyan], VectorPlot[{{gx, gy}, {gx, 0}, {0, gy}}, {x, -10, 10}, {y, -6, 6}, VectorStyle -&gt; {Black, Red, Blue}, VectorPoints -&gt; {{-10, 2}, {-5, 4}, {-5, -4}, {6, -3}}, VectorScale -&gt; .15, VectorMarkers -&gt; Placed["Arrow", "Start"]], ImageSize -&gt; 300, Frame -&gt; True ] </code></pre> <p><a href="https://i.stack.imgur.com/TxmBh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TxmBh.png" alt="enter image description here"></a></p>