Bucle de estilo de línea bivariadoHola a todos
Estoy tratando de crear una trama bivariada con un grupo que necesita diferentes estilos de línea. Sin embargo, el grupo varía según los datos proporcionados. Aquí hay una muestra de datos, donde se agrupan según su ocupación. ¿Cómo puedo crear un bucle dentro de mi función para crear un estilo de línea?
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;Tabla de datosGráficosOtrosecuencias de comandosRe: bucle de estilo de línea bivariantePuede usar una matriz asociativa para guardar la configuración (lo más probable es que lo mejor sea usar una matriz asociativa dentro de una matriz asociativa, pero me dio pereza), luego use Fit Where con EvalEvalExpr. Debe conocer la configuración de cada uno de los grupos en esta solución, pero hay formas de evitar esto según sus datos/solución:
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;
Re: bucle de estilo de línea bivariadohola, tengo un error. Y también, creo que esta parte no debería estar codificada porque, como dije, los datos varían y cambian de vez en cuando.
aa_line = Associative Array();
aa_line["Dentist"] = {"Yellow", "Dotted"};
aa_line["Doctor"] = {"Green", "DashDotDot"};
aa_line["Engineer"] = {"Red", "Solid"};
Re: bucle de estilo de línea bivariadoDespués de crear su informe bivariado, busque referencias a Line Segs usando XPath o Find Segs y luego haga algo con esas referencias:
Names Default To Here(1);
dt = Current Data Table();
biv = dt << Bivariate(Y(:weight), X(:height), Group By(:occupation), <<FIT line=""></FIT>
Re: bucle de estilo de línea bivariadoAquí hay otro enfoque para el mismo problema.
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] || "\!" )} ) )"
)
)
);