Plotting Lines in 3D

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Plotting Lines in 3D

Thomas D. Dean-2
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-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Lines in 3D

tmacchant
----- Original Message -----

> From: Thomas D. Dean
> To: "[hidden email]
> 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
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

RE: Plotting Lines in 3D

Tony Richardson
In reply to this post by Thomas D. Dean-2
> -----Original Message-----
> From: help-octave-bounces+richardson=[hidden email]
> [mailto:help-octave-bounces+richardson=[hidden email]] On
> Behalf Of Thomas D. Dean
> Sent: Wednesday, August 5, 2015 11:12 PM
> To: [hidden email]
> 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-octave mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-octave

Does this:

        plot3([X(:,1)'; X(:,4)'], [X(:,2)'; X(:,5)'],[X(:,3)'; X(:,6)']);

produce the figure you want?  (Just a single line, do not place inside a for loop.)

Tony Richardson

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

RE: Plotting Lines in 3D

Tony Richardson
In reply to this post by tmacchant
> -----Original Message-----
> From: help-octave-bounces+richardson=[hidden email]
> [mailto:help-octave-bounces+richardson=[hidden email]] On
> Behalf Of Tatsuro MATSUOKA
> Sent: Thursday, August 6, 2015 2:00 AM
> To: [hidden email]
> Subject: Re: Plotting Lines in 3D
>
> ----- Original Message -----
>
> > From: Thomas D. Dean
> > To: "[hidden email]"
> > 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
> [hidden email]
> 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


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Lines in 3D

fbarbuto
In reply to this post by Thomas D. Dean-2
Hi,

Not sure if that's what you want, but here is my approach on your problem (you may need to rotate the plot to see it in 3-D).

PS: I used a small (20x6) subset of your long 100x6 array.


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];
 
  [N,M] = size(X);
 
  for i=1:N
    figure(1)
      line([X(i,1) X(i,4)], [X(i,2) X(i,5)], [X(i,3) X(i,6)],'linestyle','-','color','b')
      hold on;
  endfor
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Lines in 3D

Thomas D. Dean-2
On 08/06/15 07:19, fbarbuto wrote:
>   for i=1:N
>      figure(1)
>        line([X(i,1) X(i,4)], [X(i,2) X(i,5)], [X(i,3)
> X(i,6)],'linestyle','-','color','b')
>        hold on;
>    endfor

Great!  I forgot about the line function.

Thanks.

I omitted in my original plot:  This is plotting values for a log
periodic dipole array similar to

http://www.antenna-theory.com/antennas/wideband/log-periodic-dipole.php

I am using the paper by Robert L. Carrel to derive the data.

Tom Dean

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Lines in 3D

fbarbuto
Thomas D. Dean-2 wrote
On 08/06/15 07:19, fbarbuto wrote:
>   for i=1:N
>      figure(1)
>        line([X(i,1) X(i,4)], [X(i,2) X(i,5)], [X(i,3)
> X(i,6)],'linestyle','-','color','b')
>        hold on;
>    endfor

Great!  I forgot about the line function.

Thanks.
I'm glad I was able to help you, but Tony Richardson's solution up above in this thread is more elegant and dispenses with the loop.

Regards,

F.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Lines in 3D

Thomas D. Dean-2
In reply to this post by Tony Richardson
On 08/06/15 06:40, Richardson, Anthony wrote:

<snip>

> 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');
>

I was having problems getting my head around the arguments, the content
and shape.

 From help plot3, the simplest form

      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.

The applicable sentence:  If all arguments are matrices, then each
column of is treated as a separate line.

octave:815> U=[X(:,1)'; X(:,4)'];
octave:816> V=[X(:,2)'; X(:,5)'];
octave:817> W=[X(:,3)'; X(:,6)'];
octave:818> plot3(U,V,W)

The first column of U,V,W, respectively define the first line.

L1_x1 = U(1,1)
L1_y1 = V(1,1)
L1_z1 = W(1,1)

L1_x2 = U(2,1)
L1_y2 = V(2,1)
L1_z2 = W(2,1)

etc.

My code is less than 30 lines.  Is this a good example for plot3?

Tom Dean


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave