嗨 JMP 社區,
我有一個腳本,它繪製基於變量(:VAR_CAT)分組的一個表中的一系列列的數據,並使用圖形生成器從另一個表中動態添加文本。 雖然這個腳本運行良好,但我在垂直放置動態添加的文本時遇到了一些困難(見下面的腳本)。
具體來說,我嘗試了不同的方法,包括:
- YMax = Col Mean (YCOL) + (Col Std Dev (YCOL)/sqrt(Col Number(YCOL)));但這並不夠好,因為這會返回整個列的 YMAX,而不是由 Overlay 變量定義的子集-> 動態計算分組到的數據的實際 Y 軸最大值的正確代碼行是什麼覆蓋類別(我知道“按”選項僅適用於 For Each Row 結構)?
- YMAX = 報告 (gb)[軸框 (2)] << 獲取最大值;它檢索 GB Y 軸的實際最大值,但這種方法會迫使我第二次評估表達式,這似乎並不高效或優雅
Names Default to Here (1);
dt1 = Data Table ("DATA_TABLE.JMP");
dt2 = Data Table ("PVALUE_TABLE.JMP");
CList = dt1 << Get Column Names(string);
gbe = Expr (Graph Builder(
Size( 497, 507 ),
Variables(
X( :DURATION ),
Y( _YS_ ),
Overlay( :VAR_CAT ),
Interval( _ES_)
),
Elements( Points( X, Y, Legend( 9 ) ), Line( X, Y, Legend( 11 ) ) ),
SendToReport(
Dispatch(
{},
_LABEL_,
ScaleBox,
{Add Ref Line( 0, "Dotted", "Black", "", 2 )}
),
Dispatch(
{},
"DURATION",
ScaleBox,
{Min( -1.0 ), Max( 16 ), Inc( 2 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
9,
Base( 0, 0, 0, Item ID( "CAT1", 1 ) ),
Base( 1, 0, 0, Item ID( "CAT2", 1 ) )
)}
),
Dispatch(
{},
"Graph Builder",
FrameBox,
{Marker Size( 6 ), Add Graphics Script(
2,
Description( "Script" ),
Text( Center Justified, {3.8, _TP_}, _TXT1_ );
Text( Center Justified, {13.6, _TP_}, _TXT2_ );
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
)
);
For (i = 5, i <= 96, i++, //96
YCOL = Column (dt1, i);
ECOL = Column (dt1, i+92);
LBL = CList [i];
YMax = Col Mean (YCOL) + (Col Std Dev (YCOL)/sqrt(Col Number(YCOL)));
YMin = Col Mean (YCOL) - (Col Std Dev (YCOL)/sqrt(Col Number(YCOL)));
YRANGE = abs (YMax - Y Min);
If (YRANGE < 1.0,
YMax = YMax + 0.5;
YMin = YMin - 0.3
);
TOPY = YMax-0.1;
PVAL1 = "p VAL " || CHAR(Format(Column(dt2, 2)[i-4], "PValue"));
PVAL2 = "p VAL " || CHAR(Format(Column(dt2, 3)[i-4], "PValue"));
gbx = Substitute (Name Expr (gbe), Expr (_YS_), YCOL,
Expr (_ES_), ECOL,
Expr (_LABEL_), LBL,
Expr (_TP_), TOPY,
Expr (_TXT1_), PVAL1,
Expr (_TXT2_), PVAL2
);
gb = Eval (gbx);
Yaxis = report (gb)[Axis Box (2)];
LocYMin = Yaxis << Get Min;
LocYMax = Yaxis << Get Max;
LocRange = LocYMax - LocYMin;
mytitle = substitute (LBL, "Least Sq Mean LOG2 FC ", "");
report (gb) [OutlineBox (1)] << Set Title (mytitle);
if(abs (LocRange) < 1.0,
Yaxis << Max (LocYMax + 0.5);
Yaxis << Min (LocYMin - 0.3);
Yaxis << Inc (0.2),.);
gb << Journal;
gb << close window;
); 也可以直接問軸箱:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
axisbox = rbiv[axis box( 1 )];
axisbox << Get Max;
(從幫助 > 腳本索引)
您可以獲取軸框的腳本,然後找到 Min() 和 Max() 設置的參數。
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), Fit Line( {Line Color( {212, 73, 88} )} ) );
y_axis_script = Report( biv )[axis box( 1 )] << get script;
/*
y_axis_script will be a list: {Scale( "Linear" ), Format( "Fixed Dec", 12, 0 ), Min( 60 ), Max( 180 ),
Interval( "Numeric" ), Inc( 20 ), Minor Ticks( 0 ), Label Row Nesting( 1 ),
Label Row(
{Automatic Font Size( 0 ), Automatic Tick Marks( 0 ), Inside Ticks( 0 ),
Label Alignment( "Near" ), Label Buffer Scale( 1 ),
Label Orientation( "Horizontal" ), Lax Label Range( 0 ),
Major Grid Line Color( -14145495 ), Minimum Depth( 0 ), Minimum Font Size( 8 ),
Minor Grid Line Color( -15790320 ), Show Major Grid( 0 ), Show Major Labels( 1 ),
Show Major Ticks( 1 ), Show Minor Grid( 0 ), Show Minor Labels( 0 ),
Show Minor Ticks( 1 ), Tick Offset( 0 ), Wrap Lines( 0 )}
)}
*/
//get the arguments for the 3rd and 4th elements of that list
minimum = Arg( y_axis_script[3], 1 );
maximum = Arg( y_axis_script[4], 1 );
嘗試將其中之一添加到圖形構建器的元素列表中:
標題框(Y,圖例(4),摘要統計(“Max”))
所以:
gbe = Expr (Graph Builder(
Size( 497, 507 ),
Variables(
X( :DURATION ),
Y( _YS_ ),
Overlay( :VAR_CAT ),
Interval( _ES_)
),
Elements(
Points( X, Y, Legend( 9 ) ),
Line( X, Y, Legend( 11),
Caption Box( Y, Legend( 4 ), Summary Statistic( "Max" ) )<BR /> ) ),<BR />//the rest of your code您可以通過在 Graph Builder 中右鍵單擊並添加標題框來直觀地執行此操作。 然後在左側的列表中將匯總統計數據更改為您需要的數據,並更改它用於計算的變量。