ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 23 Jul 2012 22:33:14 -0500Plot Series of 3D Direction Vectors (Not All from Origen)http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/Hi,
I'm trying to plot a series of vectors. I've pasted what I have below. The problem is that I want to plot the second vector, starting from the end of the first vector. If I run the commands below, I get two vectors plotted as I want (with arrows) but they are both from the origin.
I tried looking at MATPLOTLIB to see what to do but I got stuck.
Is there an easy way to plot a series of vectors in the way that I want?
a=vector([1,1,1])
b=vector([2,2,3])
aPlot=plot(a, legend_label='Vector a')
bPlot=plot(b, legend_label='Vector b')
AllPlot=aPlot+bPlot
AllPlot.show()
Sun, 22 Jul 2012 07:52:05 -0500http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/Answer by achrzesz for <p>Hi, </p>
<p>I'm trying to plot a series of vectors. I've pasted what I have below. The problem is that I want to plot the second vector, starting from the end of the first vector. If I run the commands below, I get two vectors plotted as I want (with arrows) but they are both from the origin.</p>
<p>I tried looking at MATPLOTLIB to see what to do but I got stuck. </p>
<p>Is there an easy way to plot a series of vectors in the way that I want?</p>
<pre><code>a=vector([1,1,1])
b=vector([2,2,3])
aPlot=plot(a, legend_label='Vector a')
bPlot=plot(b, legend_label='Vector b')
AllPlot=aPlot+bPlot
AllPlot.show()
</code></pre>
http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?answer=13840#post-id-13840 sage: a1=arrow((0,0,0), (1,1,1))
sage: a2=arrow((1,1,1), (2,2,3))
sage: a3=arrow((2,2,3), (3,3,1))
sage: a1+a2+a3Sun, 22 Jul 2012 08:21:21 -0500http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?answer=13840#post-id-13840Comment by kcrisman for <pre><code>sage: a1=arrow((0,0,0), (1,1,1))
sage: a2=arrow((1,1,1), (2,2,3))
sage: a3=arrow((2,2,3), (3,3,1))
sage: a1+a2+a3
</code></pre>
http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?comment=19366#post-id-19366The point being of course that a vector "always" starts at the origin, though some books would disagree.Mon, 23 Jul 2012 03:55:21 -0500http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?comment=19366#post-id-19366Comment by Justin1 for <pre><code>sage: a1=arrow((0,0,0), (1,1,1))
sage: a2=arrow((1,1,1), (2,2,3))
sage: a3=arrow((2,2,3), (3,3,1))
sage: a1+a2+a3
</code></pre>
http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?comment=19367#post-id-19367Thanks very much!Sun, 22 Jul 2012 08:53:12 -0500http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?comment=19367#post-id-19367Answer by Jason Grout for <p>Hi, </p>
<p>I'm trying to plot a series of vectors. I've pasted what I have below. The problem is that I want to plot the second vector, starting from the end of the first vector. If I run the commands below, I get two vectors plotted as I want (with arrows) but they are both from the origin.</p>
<p>I tried looking at MATPLOTLIB to see what to do but I got stuck. </p>
<p>Is there an easy way to plot a series of vectors in the way that I want?</p>
<pre><code>a=vector([1,1,1])
b=vector([2,2,3])
aPlot=plot(a, legend_label='Vector a')
bPlot=plot(b, legend_label='Vector b')
AllPlot=aPlot+bPlot
AllPlot.show()
</code></pre>
http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?answer=13844#post-id-13844You can use the `start` keyword to give a starting point or vector:
a=vector([1,1,1])
b=vector([-1,2,3])
plot(a)+plot(b, start=a)
Mon, 23 Jul 2012 22:33:14 -0500http://ask.sagemath.org/question/9172/plot-series-of-3d-direction-vectors-not-all-from-origen/?answer=13844#post-id-13844