[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Plotting Lines in 3D
From: |
Richardson, Anthony |
Subject: |
RE: Plotting Lines in 3D |
Date: |
Thu, 6 Aug 2015 13:40:44 +0000 |
> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On
> Behalf Of Tatsuro MATSUOKA
> Sent: Thursday, August 6, 2015 2:00 AM
> To: address@hidden
> Subject: Re: Plotting Lines in 3D
>
> ----- Original Message -----
>
> > From: Thomas D. Dean
> > To: "address@hidden"
> > Cc:
> > Date: 2015/8/6, Thu 13:11
> > Subject: Plotting Lines in 3D
> >
> > I have an array of 100 pairs of points, 100 rows, 6 columns, the
> > columns representing x1, y1, z1 x2, y2, z2.
> > A straight line from Point 1 to Point 2.
> >
> > I want to plot this in 3D, resulting in 100 straight lines.
> >
> > I tried
> > hold on; for idx=1:100 plot3(X(idx,:)) endfor; hold off; strange.
> >
> > plot3(X(1,:)) does not result in a straight line. The (wrong?) way I
> > read the help, it should.
> >
> > How do I do this?
> >
> > Tom Dean
> >
> > X =
> > -0.24537 0.00000 3.02878 -0.24537 -0.74948 3.02878
> > -0.21714 0.00000 3.02693 -0.21714 0.66326 3.02693
> > -0.19216 0.00000 3.02529 -0.19216 -0.58695 3.02529
> > -0.17005 0.00000 3.02385 -0.17005 0.51943 3.02385
> > -0.15049 0.00000 3.02256 -0.15049 -0.45967 3.02256
> > -0.13317 0.00000 3.02143 -0.13317 0.40679 3.02143
> > -0.11785 0.00000 3.02042 -0.11785 -0.35999 3.02042
> > -0.10430 0.00000 3.01954 -0.10430 0.31857 3.01954
> > -0.09230 0.00000 3.01875 -0.09230 -0.28192 3.01875
> > -0.08168 0.00000 3.01805 -0.08168 0.24949 3.01805
> > -0.07228 0.00000 3.01744 -0.07228 -0.22079 3.01744
> > -0.06397 0.00000 3.01689 -0.06397 0.19539 3.01689
> > -0.05661 0.00000 3.01641 -0.05661 -0.17291 3.01641
> > -0.05009 0.00000 3.01598 -0.05009 0.15302 3.01598
> > -0.04433 0.00000 3.01561 -0.04433 -0.13541 3.01561
> > -0.03923 0.00000 3.01527 -0.03923 0.11984 3.01527
> > -0.03472 0.00000 3.01498 -0.03472 -0.10605 3.01498
> > -0.03072 0.00000 3.01471 -0.03072 0.09385 3.01471
> > -0.02719 0.00000 3.01448 -0.02719 -0.08305 3.01448
> > -0.02406 0.00000 3.01428 -0.02406 0.07350 3.01428
> > -0.02129 0.00000 3.01410 -0.02129 -0.06504 3.01410
> > -0.01884 0.00000 3.01394 -0.01884 0.05756 3.01394
> > -0.01668 0.00000 3.01379 -0.01668 -0.05094 3.01379
> > -0.01476 0.00000 3.01367 -0.01476 0.04508 3.01367
> > -0.01306 0.00000 3.01356 -0.01306 -0.03989 3.01356
> > -0.24537 -0.00000 2.97122 -0.24537 0.74948 2.97122
> > -0.21714 -0.00000 2.97307 -0.21714 -0.66326 2.97307
> > -0.19216 -0.00000 2.97471 -0.19216 0.58695 2.97471
> > -0.17005 -0.00000 2.97615 -0.17005 -0.51943 2.97615
> > -0.15049 -0.00000 2.97744 -0.15049 0.45967 2.97744
> > -0.13317 -0.00000 2.97857 -0.13317 -0.40679 2.97857
> > -0.11785 -0.00000 2.97958 -0.11785 0.35999 2.97958
> > -0.10430 -0.00000 2.98046 -0.10430 -0.31857 2.98046
> > -0.09230 -0.00000 2.98125 -0.09230 0.28192 2.98125
> > -0.08168 -0.00000 2.98195 -0.08168 -0.24949 2.98195
> > -0.07228 -0.00000 2.98256 -0.07228 0.22079 2.98256
> > -0.06397 -0.00000 2.98311 -0.06397 -0.19539 2.98311
> > -0.05661 -0.00000 2.98359 -0.05661 0.17291 2.98359
> > -0.05009 -0.00000 2.98402 -0.05009 -0.15302 2.98402
> > -0.04433 -0.00000 2.98439 -0.04433 0.13541 2.98439
> > -0.03923 -0.00000 2.98473 -0.03923 -0.11984 2.98473
> > -0.03472 -0.00000 2.98502 -0.03472 0.10605 2.98502
> > -0.03072 -0.00000 2.98529 -0.03072 -0.09385 2.98529
> > -0.02719 -0.00000 2.98552 -0.02719 0.08305 2.98552
> > -0.02406 -0.00000 2.98572 -0.02406 -0.07350 2.98572
> > -0.02129 -0.00000 2.98590 -0.02129 0.06504 2.98590
> > -0.01884 -0.00000 2.98606 -0.01884 -0.05756 2.98606
> > -0.01668 -0.00000 2.98621 -0.01668 0.05094 2.98621
> > -0.01476 -0.00000 2.98633 -0.01476 -0.04508 2.98633
> > -0.01306 -0.00000 2.98644 -0.01306 0.03989 2.98644
> > -0.24537 0.00000 3.02878 -0.21714 0.00000 3.02693
> > -0.21714 0.00000 3.02693 -0.19216 0.00000 3.02529
> > -0.19216 0.00000 3.02529 -0.17005 0.00000 3.02385
> > -0.17005 0.00000 3.02385 -0.15049 0.00000 3.02256
> > -0.15049 0.00000 3.02256 -0.13317 0.00000 3.02143
> > -0.13317 0.00000 3.02143 -0.11785 0.00000 3.02042
> > -0.11785 0.00000 3.02042 -0.10430 0.00000 3.01954
> > -0.10430 0.00000 3.01954 -0.09230 0.00000 3.01875
> > -0.09230 0.00000 3.01875 -0.08168 0.00000 3.01805
> > -0.08168 0.00000 3.01805 -0.07228 0.00000 3.01744
> > -0.07228 0.00000 3.01744 -0.06397 0.00000 3.01689
> > -0.06397 0.00000 3.01689 -0.05661 0.00000 3.01641
> > -0.05661 0.00000 3.01641 -0.05009 0.00000 3.01598
> > -0.05009 0.00000 3.01598 -0.04433 0.00000 3.01561
> > -0.04433 0.00000 3.01561 -0.03923 0.00000 3.01527
> > -0.03923 0.00000 3.01527 -0.03472 0.00000 3.01498
> > -0.03472 0.00000 3.01498 -0.03072 0.00000 3.01471
> > -0.03072 0.00000 3.01471 -0.02719 0.00000 3.01448
> > -0.02719 0.00000 3.01448 -0.02406 0.00000 3.01428
> > -0.02406 0.00000 3.01428 -0.02129 0.00000 3.01410
> > -0.02129 0.00000 3.01410 -0.01884 0.00000 3.01394
> > -0.01884 0.00000 3.01394 -0.01668 0.00000 3.01379
> > -0.01668 0.00000 3.01379 -0.01476 0.00000 3.01367
> > -0.01476 0.00000 3.01367 -0.01306 0.00000 3.01356
> > -0.01306 0.00000 3.01356 0.00000 0.00000 3.01270
> > -0.24537 0.00000 2.97122 -0.21714 0.00000 2.97307
> > -0.21714 0.00000 2.97307 -0.19216 0.00000 2.97471
> > -0.19216 0.00000 2.97471 -0.17005 0.00000 2.97615
> > -0.17005 0.00000 2.97615 -0.15049 0.00000 2.97744
> > -0.15049 0.00000 2.97744 -0.13317 0.00000 2.97857
> > -0.13317 0.00000 2.97857 -0.11785 0.00000 2.97958
> > -0.11785 0.00000 2.97958 -0.10430 0.00000 2.98046
> > -0.10430 0.00000 2.98046 -0.09230 0.00000 2.98125
> > -0.09230 0.00000 2.98125 -0.08168 0.00000 2.98195
> > -0.08168 0.00000 2.98195 -0.07228 0.00000 2.98256
> > -0.07228 0.00000 2.98256 -0.06397 0.00000 2.98311
> > -0.06397 0.00000 2.98311 -0.05661 0.00000 2.98359
> > -0.05661 0.00000 2.98359 -0.05009 0.00000 2.98402
> > -0.05009 0.00000 2.98402 -0.04433 0.00000 2.98439
> > -0.04433 0.00000 2.98439 -0.03923 0.00000 2.98473
> > -0.03923 0.00000 2.98473 -0.03472 0.00000 2.98502
> > -0.03472 0.00000 2.98502 -0.03072 0.00000 2.98529
> > -0.03072 0.00000 2.98529 -0.02719 0.00000 2.98552
> > -0.02719 0.00000 2.98552 -0.02406 0.00000 2.98572
> > -0.02406 0.00000 2.98572 -0.02129 0.00000 2.98590
> > -0.02129 0.00000 2.98590 -0.01884 0.00000 2.98606
> > -0.01884 0.00000 2.98606 -0.01668 0.00000 2.98621
> > -0.01668 0.00000 2.98621 -0.01476 0.00000 2.98633
> > -0.01476 0.00000 2.98633 -0.01306 0.00000 2.98644
> > -0.01306 0.00000 2.98644 0.00000 0.00000 2.98730
> >
>
>
>
>
> >> help plot3
> 'plot3' is a function from the file C:\octave\Octave-
> 4.0.0\share\octave\4.0.0\m\plot\draw\plot3.
> m
>
> -- Function File: plot3 (X, Y, Z)
> -- Function File: plot3 (X, Y, Z, PROP, VALUE, ...)
> -- Function File: plot3 (X, Y, Z, FMT)
> -- Function File: plot3 (X, CPLX)
> -- Function File: plot3 (CPLX)
> -- Function File: plot3 (HAX, ...)
> -- Function File: H = plot3 (...)
> Produce 3-D plots.
>
> Many different combinations of arguments are possible. The
> simplest form is
>
> plot3 (X, Y, Z)
>
> in which the arguments are taken to be the vertices of the points
> to be plotted in three dimensions. If all arguments are vectors
> of the same length, then a single continuous line is drawn. If
> all arguments are matrices, then each column of is treated as a
> separate line. No attempt is made to transpose the arguments to
> make the number of rows match.
>
> Seeing the above, it is obvious that
> plot3(X(1,:)) does not result in a straight line.
>
>
> I tried to plot only the first line,
>
> >> X=[-0.24537 0.00000 3.02878 -0.24537 -0.74948 3.02878];
> >> plot3([X(1,1) X(1,4)], [X(1,2) X(1,5)], [X(1,3) X(1,6)]);
>
> gives a straight line.
>
> Please try
> hold on; for idx=1:100; plot3([X(idx,1) X(idx,4)], [X(idx,2) X(idx,5)],
> [X(idx,3) X(idx,6)]); endfor; hold off;
>
>
> The above is not elegant so that other people may give better solutions.
>
> Tatsuro
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave
The above line:
hold on; for idx=1:100; plot3([X(idx,1) X(idx,4)], [X(idx,2) X(idx,5)],
[X(idx,3) X(idx,6)]); endfor; hold off;
does not work, although it appears as if it should. The initial 'hold on'
seems to hold a 2D plot instead of a 3D
one. Moving the 'hold on' line inside the for loop fixes the problem.
for idx=1:100; plot3([X(idx,1) X(idx,4)], [X(idx,2) X(idx,5)], [X(idx,3)
X(idx,6)]); hold on; endfor; hold off;
In a separate post I give:
plot3([X(:,1)'; X(:,4)'], [X(:,2)'; X(:,5)'],[X(:,3)'; X(:,6)']);
or (to plot all lines in the same color):
plot3([X(:,1)'; X(:,4)'], [X(:,2)'; X(:,5)'],[X(:,3)'; X(:,6)'],'b');
as a solution that does not require a for loop or a hold.
Tony Richardson