雙變量線型循環大家好
我正在嘗試使用需要不同線條樣式的組創建一個雙變量圖。 然而,該組根據給定的數據而變化。 這是一個示例數據,其中根據職業進行分組。 如何在函數內創建循環來創建線條樣式?
biv = Bivariate( Y( :weight ), X( :height ),
Group By( :occupation ), << Fit Line );
rbiv = biv << report << Show Points( 1 );
ymin = rbiv[Axis Box(1)] << Get Min;
ymax = rbiv[Axis Box(1)] << Get Max;
xmin = rbiv[Axis Box(2)] << Get Min;
xmax = rbiv[Axis Box(2)] << Get Max;
rbiv[Frame Box( 1 )] << {Frame Size( 205, 164 ), Marker Size( 2 ), Line Width Scale( 2 )};
rbiv [Border Box (2)] << Sides(0);
rbiv[Axis Box( 1 )] << Format( "Best", 12 ) << Tick Font( style( 1 ), size( 9 ) )
<< Show Major Grid( 1 ) << Show Minor Grid( 1 ) << Show Minor Ticks( 1 );
rbiv[Axis Box( 2 )] << Format( "Best", 12 ) << Tick Font( style( 1 ), size( 9 ) )
<< Show Major Grid( 1 ) << Show Minor Grid( 1 ) << Show Minor Ticks( 1 );
rbiv[Text Edit Box( 1 )] << Set Font Size( 10 ) << Set Font Style( "Bold" );
rbiv[Text Edit Box( 2 )] << Set Font Size( 10 ) << Set Font Style( "Bold" );
rbiv[Outline Box( 2 )] << Close All Below;
rbiv[Outline Box( 2 )] << Close All Like This;高級統計建模消費者和市場研究數據混合和清理數據探索和可視化大規模定制質量和工藝工程回复:雙變量線型循環完全錯過了! 謝謝,我完全明白了
回复:雙變量線型循環有 2 個問題。您在兩個不同的循環中使用索引變量“i”。第二個循環正在更改“i”的值,當第一個循環啟動第二個循環時,“i”的值會增加。它發現“i”大於 nitems(colnamex),因此它停止循環。 如果將“i”更改為“k”
For(k = 1, k <= Nitems(colnamex), k++,
bivplot_line1( colname[1],colnamex[ik) );
代碼將循環。
第二個問題是您指定了 2 列,兄弟姐妹年齡和年齡向量,它們不是在二元變量中使用的有效列。因此,在您的示例中,代碼只能正確運行 2 列。
回复:雙變量線型循環嗨特克斯尼爾森,
線條圖例工作正常,但是當我嘗試將此循環放入需要生成多個圖的函數中時,它只生成一個圖,而它應該是四個(4 y 列)。
請幫助循環該函數
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
bivplot_line1 = Function({ ycol, xcol }, {plot},
biv = Bivariate( Y( Column( dt, ycol ) ), X( Column( dt, xcol )) );
rbiv = biv << report << Show Points( 1 );
styleList = {"Solid", "Dashed", "Dotted", "DashDot", "DashDotDot"};
Summarize( dt, groups = by ( :Sex ) );
mystyle = styleList[2];
For( i = 1, i <= N Items( groups ), i++,
Eval(
Parse( "biv << Fit Where( :Sex == \!"" || groups[i] || "\!",
Fit Line( { Line Style( \!"" || styleList[i] || "\!" )} ) )"
)
)
);
);
colname = {"weight"};
colnamex = {"age", "height", "siblings ages", "age vector"};
For(i = 1, i <= Nitems(colnamex), i++,
bivplot_line1( colname[1],colnamex[i]) );
回复:雙變量線型循環這是解決同一問題的另一種方法
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
obj = dt << Bivariate( Y( :weight ), X( :height ) );
styleList = {"Solid", "Dashed", "Dotted", "DashDot", "DashDotDot"};
Summarize( dt, groups = by( :sex ) );
mystyle = styleList[2];
For( i = 1, i <= N Items( groups ), i++,
Eval(
Parse(
"obj << Fit Where( :sex == \!"" || groups[i] || "\!",
Fit Line( { Line Style( \!"" ||
styleList[i] || "\!" )} ) )"
)
)
);回复:雙變量線型循環創建雙變量報告後,使用 XPath 或 Find Segs 查找對 Line Segs 的引用,然後對這些引用執行某些操作:
Names Default To Here(1);
dt = Current Data Table();
biv = dt << Bivariate(Y(:weight), X(:height), Group By(:occupation), <<FIT line=""></FIT>
回复:雙變量線型循環我不得不問,如果您不知道如何設計線條樣式,就像您不知道需要多少種樣式一樣,您將如何創建線條樣式?
該錯誤很可能是由於您使用早於 16 的 JMP 版本引起的。 必須將循環更改為常規 For 循環,而不是 For Each(簡單更改)。
回复:雙變量線型循環你好,我收到一個錯誤。 而且,我認為這部分不應該被硬編碼,因為就像我說的,數據是變化的並且不時變化
aa_line = Associative Array();
aa_line["Dentist"] = {"Yellow", "Dotted"};
aa_line["Doctor"] = {"Green", "DashDotDot"};
aa_line["Engineer"] = {"Red", "Solid"};
回复:雙變量線型循環您可以使用關聯數組來保存設置(最有可能的最好方法是在關聯數組中使用關聯數組,但我很懶),然後將 FitWhere 與 EvalEvalExpr 一起使用。 您需要了解此解決方案中每個組的設置,但根據您的數據/解決方案,有一些方法可以解決此問題:
Names Default To Here(1);
dt = Current Data Table();
biv = Bivariate(Y(:weight), X(:height), Group By(:occupation));
rbiv = biv << report << Show Points(1);
aa_line = Associative Array();
aa_line["Dentist"] = {"Yellow", "Dotted"};
aa_line["Doctor"] = {"Green", "DashDotDot"};
aa_line["Engineer"] = {"Red", "Solid"};
For Each({{key_occ, value_list}}, aa_line,
Eval(Eval Expr(biv << Fit Where(:occupation == Expr(key_occ), Fit Line({Line Color(Expr(value_list[1])), Line Style(Expr(value_list[2]))}))))
);
rbiv = biv << report << Show Points(1);
ymin = rbiv[Axis Box(1)] << Get Min;
ymax = rbiv[Axis Box(1)] << Get Max;
xmin = rbiv[Axis Box(2)] << Get Min;
xmax = rbiv[Axis Box(2)] << Get Max;
rbiv[Frame Box(1)] << {Frame Size(205, 164), Marker Size(2), Line Width Scale(2)};
rbiv[Border Box(2)] << Sides(0);
rbiv[Axis Box(1)] << Format("Best", 12) << Tick Font(style(1), size(9)) << Show Major Grid(1) << Show Minor Grid(1) << Show Minor Ticks(1);
rbiv[Axis Box(2)] << Format("Best", 12) << Tick Font(style(1), size(9)) << Show Major Grid(1) << Show Minor Grid(1) << Show Minor Ticks(1);
rbiv[Text Edit Box(1)] << Set Font Size(10) << Set Font Style("Bold");
rbiv[Text Edit Box(2)] << Set Font Size(10) << Set Font Style("Bold");
rbiv[Outline Box(2)] << Close All Below;
rbiv[Outline Box(2)] << Close All Like This;