Author |
Topic |
|
wz1416scripps
USA
24 Posts |
Posted - 02/05/2016 : 2:31:07 PM
|
Origin Ver. and Service Release (Select Help-->About Origin):Originpro 2015 Operating System:Win8.1
Hi,
I have 63 data points in a scatter plot.Now I want to plot the connecting lines for all the possible pair of data points, i.e. (1953 lines for 1953 patterns of pair). How can I do that?
Thanks, Chao.
|
|
cpyang
USA
1406 Posts |
Posted - 02/06/2016 : 8:43:41 PM
|
There is no built-in plot type for that, but you can use the following Labtalk code to construct the data to make this plot. The code assume you have XY data in a worksheet, and then two new XY will be generated, and you just select these two column to plot as line-symbol.
//assume col 1, 2 to be source XY data
//add col 3 4 as date to be generated to plot as Line-Symbol
if(wks.ncols<4)
wks.ncols=4;
range ax = 1;//Source X
range ay = 2;//Source Y
range bx = 3;//Calculated X to plot
range by = 4;//Calculated Y to plot
bx.type=4;//X
by.type=1;//Y
int npts = ax.getsize();
for(int ii = 1, jj=1;ii<=npts;ii++)
{
for(int kk=ii+1;kk<=npts;kk++, jj++)
{
bx[jj] = ax[ii];
by[jj] = ay[ii];
jj++;
bx[jj] = ax[kk];
by[jj] = ay[kk];
jj++;
bx[jj] = 0/0;
by[jj] = 0/0;
}
}
|
|
|
wz1416scripps
USA
24 Posts |
Posted - 02/19/2016 : 1:25:12 PM
|
Thanks,It works. If I want to only show the lines within certain distance range, how can I do that?
For example, only show the lines with the length in the '0~0.5' range.
Thanks, Chao.
quote: Originally posted by cpyang
There is no built-in plot type for that, but you can use the following Labtalk code to construct the data to make this plot. The code assume you have XY data in a worksheet, and then two new XY will be generated, and you just select these two column to plot as line-symbol.
//assume col 1, 2 to be source XY data
//add col 3 4 as date to be generated to plot as Line-Symbol
if(wks.ncols<4)
wks.ncols=4;
range ax = 1;//Source X
range ay = 2;//Source Y
range bx = 3;//Calculated X to plot
range by = 4;//Calculated Y to plot
bx.type=4;//X
by.type=1;//Y
int npts = ax.getsize();
for(int ii = 1, jj=1;ii<=npts;ii++)
{
for(int kk=ii+1;kk<=npts;kk++, jj++)
{
bx[jj] = ax[ii];
by[jj] = ay[ii];
jj++;
bx[jj] = ax[kk];
by[jj] = ay[kk];
jj++;
bx[jj] = 0/0;
by[jj] = 0/0;
}
}
|
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 02/19/2016 : 5:55:05 PM
|
Hi wz1416scripps,
> For example, only show the lines with the length in the '0~0.5' range.
You can add an extra column, then using Set Column Values tool, calculate the distance from the previous XY pair to the current pair: e.g., sqrt((col(3)[i]-col(3)[i+1])^2+(col(4)[i]-col(4)[i+1])^2) in the sample below.
Then, add a filter to this distance column, and put the condition to keep only within the desired range or the missing value: e.g., x<0.3 || x==1/0 in the sample below.
Hope this helps.
--Hideo Fujii OriginLab |
Edited by - Hideo Fujii on 02/19/2016 6:04:26 PM |
|
|
wz1416scripps
USA
24 Posts |
Posted - 07/27/2016 : 7:01:05 PM
|
Thanks. It works.
Now I have another problem. I want to plot all the lines connecting datapoints that have (x, y, z), i.e. connecting dots in 3D space.
How can I do that?
Thanks, Chao.
quote: Originally posted by Hideo Fujii
Hi wz1416scripps,
> For example, only show the lines with the length in the '0~0.5' range.
You can add an extra column, then using Set Column Values tool, calculate the distance from the previous XY pair to the current pair: e.g., sqrt((col(3)[i]-col(3)[i+1])^2+(col(4)[i]-col(4)[i+1])^2) in the sample below.
Then, add a filter to this distance column, and put the condition to keep only within the desired range or the missing value: e.g., x<0.3 || x==1/0 in the sample below.
Hope this helps.
--Hideo Fujii OriginLab
|
Edited by - wz1416scripps on 07/27/2016 7:05:58 PM |
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 07/28/2016 : 3:56:20 PM
|
Hi wz1416scripps,
> I want to plot all the lines connecting data points that have (x, y, z), i.e. connecting dots in 3D space.
You can simply expand the CP's code to 3D such that://////////////////////////////////////
if(wks.ncols<6) wks.ncols=6;
range ax=col(1), ay=col(2), az=col(3); //Source X,Y,Z
range bx=4, by=5, bz=6; //Calculated X,Y,Z to plot
bx.type=4; by.type=1; bz.type=6; //Column designations X, Y, Z
int npts = ax.getsize();
for(ii=1, jj=1; ii<=npts; ii++) {
for(kk=ii+1; kk<=npts; kk++,jj++) {
bx[jj] = ax[ii]; by[jj] = ay[ii]; bz[jj] = az[ii];
jj++;
bx[jj] = ax[kk]; by[jj] = ay[kk]; bz[jj] = az[kk];
jj++;
bx[jj] = 0/0; by[jj] = 0/0; bz[jj] = 0/0;
}
}
////////////////////////////////////// Then, you can make a 3D Trajectory plot ("Plot> 3D Symbol/Bar/Vector> 3D Trajectory" menu). See the sample below. (Note: Drop lines are hidden, and similar to the 2D sample, only line segments with distance<0.3 are displayed by using the same filter. You notice that the distance in the column G has the formula using "distance3D" built-in function.)
I hope this is what you wanted.
--Hideo Fujii OriginLab |
Edited by - Hideo Fujii on 07/29/2016 09:55:55 AM |
|
|
|
Topic |
|
|
|