我對你的腳本進行了一些調整,但主要問題是你的程式碼假設你擁有 Group1、Group2 和 Group3 的所有組合,而在你提供的資料中你沒有,所以程式找不到任何資料來分析。
names default to here(1);
dtt = Current Data Table();
Summarize( dtt, byGroup1 = by( :var1 ) );
Summarize( dtt, byGroup2 = by( :var2 ) );
Summarize( dtt, byGroup3 = by( :var3 ) );
For( ii = 1, ii < N Items( byGroup1 ), ii++,
For( jj = 1, jj < N Items( byGroup2 ), jj++,
For( kk = 1, kk < N Items( byGroup3 ), kk++,
dtt << select where( :var1 == byGroup1[ii] & :var2 == byGroup2[jj] & :var3 == byGroup3[kk] );
show(ii,jj,kk,bygroup1[ii],bygroup2[jj],bygroup3[kk]);
sel = dtt << get selected rows;
If( n rows(sel) > 0,
show("inside",ii,jj,kk);
dt = dtt << subset( selected rows(1), selected columns(0));
gb = dt << Graph Builder(
Size( 531, 456 ),
Show Control Panel( 0 ),
Variables( X( :x axis ), Y( :y axis ), Overlay( :legend ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"x axis",
ScaleBox,
{Format( "Best", 12 ), Min( 2.273568 ), Max( 3.00134902479339 ), Inc( 0.1 ), Minor Ticks( 0 )}
)
)
);
// Add a simple graphics script to connect the points
Report( gb )[FrameBox( 1 )] << add graphics script(
Summarize( dt, byGroup = by( :legend ) );
colorList = {"Blue", "Red", "Green"};
Fill Pattern( [0] );
For( i = 1, i <= N Items( byGroup ), i++,
Pen Color( colorList[i] );
theRows = dt << get rows where( :legend == byGroup[i] & :Label != "i" );
// Add the first value as the last value to complete the object
theRows = theRows |/ theRows[1];
xMatrix = :x axis[theRows];
yMatrix = :y axis[theRows];
Line( xMatrix, yMatrix );
);
););
)
)
);非常感謝您的幫忙。 非常欣賞。 我還有一個問題,如果您能幫忙,我將不勝感激。
我有一個大表,由許多子集(我發送給您的表)組成,並由另外三個附加列控制。 我試圖建立表的子集(每個表都像我發送給您的子集)並在三個 For 循環中應用下面的程式碼。 不知何故,子集表生成不起作用。
dtt = Current Data Table();
Summarize( dtt, byGroup1 = by( :var1 ) );
Summarize( dtt, byGroup2 = by( :var2 ) );
Summarize( dtt, byGroup3 = by( :var3 ) );
For( ii = 1, ii < N Items( byGroup1 ), ii++,
For( jj = 1, jj < N Items( byGroup2 ), jj++,
For( kk = 1, kk < N Items( byGroup3 ), kk++,
dt = dtt << subset(
select where( :var1 == byGroup1[ii] & :var2 == byGroup2[jj] & :var3 == byGroup3[kk] )
);
gb = dt << Graph Builder(
Size( 531, 456 ),
Show Control Panel( 0 ),
Variables( X( :x axis ), Y( :y axis ), Overlay( :legend ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"x axis",
ScaleBox,
{Format( "Best", 12 ), Min( 2.273568 ), Max( 3.00134902479339 ), Inc( 0.1 ),
Minor Ticks( 0 )}
)
)
);
// Add a simple graphics script to connect the points
Report( gb )[FrameBox( 1 )] << add graphics script(
Summarize( dt, byGroup = by( :legend ) );
colorList = {"Blue", "Red", "Green"};
Fill Pattern( [0] );
For( i = 1, i <= N Items( byGroup ), i++,
Pen Color( colorList[i] );
theRows = dt << get rows where( :legend == byGroup[i] & :Label != "i" );
// Add the first value as the last value to complete the object
theRows = theRows |/ theRows[1];
xMatrix = :x axis[theRows];
yMatrix = :y axis[theRows];
Line( xMatrix, yMatrix );
);
);
);
);
);
| x 軸 |
y 軸 |
標籤 |
傳奇 |
變數1 |
變數2 |
變數3 |
| 2.385649 |
2.260832 |
A |
設定1 |
康1 |
康11 |
康111 |
| 2.385782 |
2.261566 |
A |
設定2 |
康1 |
康11 |
康111 |
| 2.418368 |
2.291898 |
A |
設定3 |
康1 |
康11 |
康111 |
| 2.297858 |
2.445948 |
乙 |
設定1 |
康1 |
康11 |
康111 |
| 2.297908 |
2.446336 |
乙 |
設定2 |
康1 |
康11 |
康111 |
| 2.331846 |
2.475788 |
乙 |
設定3 |
康1 |
康11 |
康111 |
| 2.385649 |
2.649821 |
C |
設定1 |
康1 |
康11 |
康111 |
| 2.385782 |
2.649944 |
C |
設定2 |
康1 |
康11 |
康111 |
| 2.418368 |
2.674239 |
C |
設定3 |
康1 |
康11 |
康111 |
| 2.587473 |
2.730171 |
d |
設定1 |
康1 |
康11 |
康111 |
| 2.587765 |
2.730239 |
d |
設定2 |
康1 |
康11 |
康111 |
| 2.618502 |
2.753243 |
d |
設定3 |
康1 |
康11 |
康111 |
| 2.817405 |
2.649821 |
e |
設定1 |
康1 |
康11 |
康111 |
| 2.817657 |
2.649944 |
e |
設定2 |
康1 |
康11 |
康111 |
| 2.839774 |
2.674239 |
e |
設定3 |
康1 |
康11 |
康111 |
| 2.905865 |
2.445948 |
F |
設定1 |
康1 |
康11 |
康111 |
| 2.90615 |
2.446336 |
F |
設定2 |
康1 |
康11 |
康111 |
| 2.925915 |
2.475788 |
F |
設定3 |
康1 |
康11 |
康111 |
| 2.817405 |
2.260832 |
G |
設定1 |
康1 |
康11 |
康111 |
| 2.817657 |
2.261566 |
G |
設定2 |
康1 |
康11 |
康111 |
| 2.839774 |
2.291898 |
G |
設定3 |
康1 |
康11 |
康111 |
| 2.587473 |
2.181713 |
H |
設定1 |
康1 |
康11 |
康111 |
| 2.587765 |
2.182677 |
H |
設定2 |
康1 |
康11 |
康111 |
| 2.618502 |
2.213788 |
H |
設定3 |
康1 |
康11 |
康111 |
| 2.587473 |
2.445948 |
我 |
設定1 |
康1 |
康11 |
康111 |
| 2.587765 |
2.446336 |
我 |
設定2 |
康1 |
康11 |
康111 |
| 2.618502 |
2.475788 |
我 |
設定3 |
康1 |
康11 |
康111 |
| 2.624214 |
2.486915 |
A |
設定1 |
康2 |
康22 |
康222 |
| 2.62436 |
2.487723 |
A |
設定2 |
康2 |
康22 |
康222 |
| 2.660205 |
2.521088 |
A |
設定3 |
康2 |
康22 |
康222 |
| 2.527644 |
2.690543 |
乙 |
設定1 |
康2 |
康22 |
康222 |
| 2.527699 |
2.69097 |
乙 |
設定2 |
康2 |
康22 |
康222 |
| 2.565031 |
2.723367 |
乙 |
設定3 |
康2 |
康22 |
康222 |
| 2.624214 |
2.914803 |
C |
設定1 |
康2 |
康22 |
康222 |
| 2.62436 |
2.914938 |
C |
設定2 |
康2 |
康22 |
康222 |
| 2.660205 |
2.941663 |
C |
設定3 |
康2 |
康22 |
康222 |
| 2.84622 |
3.003188 |
d |
設定1 |
康2 |
康22 |
康222 |
| 2.846542 |
3.003263 |
d |
設定2 |
康2 |
康22 |
康222 |
| 2.880352 |
3.028567 |
d |
設定3 |
康2 |
康22 |
康222 |
| 3.099146 |
2.914803 |
e |
設定1 |
康2 |
康22 |
康222 |
| 3.099423 |
2.914938 |
e |
設定2 |
康2 |
康22 |
康222 |
| 3.123751 |
2.941663 |
e |
設定3 |
康2 |
康22 |
康222 |
| 3.196452 |
2.690543 |
F |
設定1 |
康2 |
康22 |
康222 |
| 3.196765 |
2.69097 |
F |
設定2 |
康2 |
康22 |
康222 |
| 3.218507 |
2.723367 |
F |
設定3 |
康2 |
康22 |
康222 |
| 3.099146 |
2.486915 |
G |
設定1 |
康2 |
康22 |
康222 |
| 3.099423 |
2.487723 |
G |
設定2 |
康2 |
康22 |
康222 |
| 3.123751 |
2.521088 |
G |
設定3 |
康2 |
康22 |
康222 |
| 2.84622 |
2.399884 |
H |
設定1 |
康2 |
康22 |
康222 |
| 2.846542 |
2.400945 |
H |
設定2 |
康2 |
康22 |
康222 |
| 2.880352 |
2.435167 |
H |
設定3 |
康2 |
康22 |
康222 |
| 2.84622 |
2.690543 |
我 |
設定1 |
康2 |
康22 |
康222 |
| 2.846542 |
2.69097 |
我 |
設定2 |
康2 |
康22 |
康222 |
| 2.880352 |
2.723367 |
我 |
設定3 |
康2 |
康22 |
康222 |
| 2.743496 |
2.599957 |
A |
設定1 |
康3 |
康32 |
康33 |
| 2.743649 |
2.600801 |
A |
設定2 |
康3 |
康32 |
康33 |
| 2.781123 |
2.635683 |
A |
設定3 |
康3 |
康32 |
康33 |
| 2.642537 |
2.81284 |
乙 |
設定1 |
康3 |
康32 |
康33 |
| 2.642594 |
2.813286 |
乙 |
設定2 |
康3 |
康32 |
康33 |
| 2.681623 |
2.847156 |
乙 |
設定3 |
康3 |
康32 |
康33 |
| 2.743496 |
3.047294 |
C |
設定1 |
康3 |
康32 |
康33 |
| 2.743649 |
3.047436 |
C |
設定2 |
康3 |
康32 |
康33 |
| 2.781123 |
3.075375 |
C |
設定3 |
康3 |
康32 |
康33 |
| 2.975594 |
3.139697 |
d |
設定1 |
康3 |
康32 |
康33 |
| 2.97593 |
3.139775 |
d |
設定2 |
康3 |
康32 |
康33 |
| 3.011277 |
3.166229 |
d |
設定3 |
康3 |
康32 |
康33 |
| 3.240016 |
3.047294 |
e |
設定1 |
康3 |
康32 |
康33 |
| 3.240306 |
3.047436 |
e |
設定2 |
康3 |
康32 |
康33 |
| 3.26574 |
3.075375 |
e |
設定3 |
康3 |
康32 |
康33 |
| 3.341745 |
2.81284 |
F |
設定1 |
康3 |
康32 |
康33 |
| 3.342073 |
2.813286 |
F |
設定2 |
康3 |
康32 |
康33 |
| 3.364802 |
2.847156 |
F |
設定3 |
康3 |
康32 |
康33 |
| 3.240016 |
2.599957 |
G |
設定1 |
康3 |
康32 |
康33 |
| 3.240306 |
2.600801 |
G |
設定2 |
康3 |
康32 |
康33 |
| 3.26574 |
2.635683 |
G |
設定3 |
康3 |
康32 |
康33 |
| 2.975594 |
2.50897 |
H |
設定1 |
康3 |
康32 |
康33 |
| 2.97593 |
2.510079 |
H |
設定2 |
康3 |
康32 |
康33 |
| 3.011277 |
2.545856 |
H |
設定3 |
康3 |
康32 |
康33 |
| 2.975594 |
2.81284 |
我 |
設定1 |
康3 |
康32 |
康33 |
| 2.97593 |
2.813286 |
我 |
設定2 |
康3 |
康32 |
康33 |
| 3.011277 |
2.847156 |
我 |
設定3 |
康3 |
康32 |
康33 |
如果將簡單的圖形腳本新增到圖形產生器物件中,您可以獲得您想要的

names default to here(1);
// Create the data table
dt = New Table( "Example",
Add Rows( 27 ),
New Script(
"Source",
Data Table( "Untitled 60" ) << Split(
Split By( :Column 2 ),
Split( :Column 1 ),
Sort by Column Property
)
),
New Column( "x axis",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[2.3856, 2.3858, 2.4184, 2.2979, 2.2979, 2.3318, 2.3856, 2.3858, 2.4184,
2.5875, 2.5878, 2.6185, 2.8174, 2.8177, 2.8398, 2.9059, 2.9062, 2.9259,
2.8174, 2.8177, 2.8398, 2.5875, 2.5878, 2.6185, 2.5875, 2.5878, 2.6185]
)
),
New Column( "y axis",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[2.2608, 2.2616, 2.2919, 2.4459, 2.4463, 2.4758, 2.6498, 2.6499, 2.6742,
2.7302, 2.7302, 2.7532, 2.6498, 2.6499, 2.6742, 2.4459, 2.4463, 2.4758,
2.2608, 2.2616, 2.2919, 2.1817, 2.1827, 2.2138, 2.4459, 2.4463, 2.4758]
)
),
New Column( "label",
Character,
"Nominal",
Set Values(
{"a", "a", "a", "b", "b", "b", "c", "c", "c", "d", "d", "d", "e", "e",
"e", "f", "f", "f", "g", "g", "g", "h", "h", "h", "i", "i", "i"}
)
),
New Column( "legend",
Character,
"Nominal",
Set Values(
{"set1", "set2", "set3", "set1", "set2", "set3", "set1", "set2", "set3",
"set1", "set2", "set3", "set1", "set2", "set3", "set1", "set2", "set3",
"set1", "set2", "set3", "set1", "set2", "set3", "set1", "set2", "set3"}
)
)
);
// Draw the scatterplot
gb = dt << Graph Builder(
Size( 531, 456 ),
Show Control Panel( 0 ),
Variables( X( :x axis ), Y( :y axis ), Overlay( :legend ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"x axis",
ScaleBox,
{Format( "Best", 12 ), Min( 2.273568 ), Max( 3.00134902479339 ),
Inc( 0.1 ), Minor Ticks( 0 )}
)
)
);
// Add a simple graphics script to connect the points
Report( gb )[FrameBox( 1 )] << add graphics script(
Summarize( dt, byGroup = by( :legend ) );
colorList = {"Blue","Red","Green"};
fill pattern( [0] );
For( i = 1, i <= N Items( byGroup ), i++,
Pen Color(colorList[i]);
theRows = dt << get rows where( :legend == byGroup[i] & :Label != "i" );
// Add the first value as the last value to complete the object
theRows = theRows |/ theRows[1];
xMatrix = :x axis[theRows];
yMatrix = :y axis[theRows];
line( xMatrix, yMatrix );
);
);