Boucle de style de ligne bivariéesalut tout le monde
J'essaie de créer un graphique bivarié avec un groupe nécessitant différents styles de ligne. Cependant, le groupe varie en fonction des données fournies. Voici un exemple de données, où il est regroupé en fonction de leur profession. Comment puis-je créer une boucle dans ma fonction pour créer un style de ligne ?
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;Tableau de donnéesGraphiqueAutreScriptRe : Boucle de style de ligne bivariéeVous pouvez utiliser un tableau associatif pour enregistrer les paramètres (le mieux serait probablement d'utiliser un tableau associatif dans un tableau associatif, mais je suis devenu paresseux), puis utilisez Fit Where avec EvalEvalExpr. Vous devez connaître les paramètres de chacun des groupes de cette solution, mais il existe des moyens de contourner cela en fonction de vos données/solution :
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 : Boucle de style de ligne bivariéeSalut, j'ai eu une erreur. Et aussi, je pense que cette partie ne devrait pas être codée en dur car comme je l'ai dit, les données varient et changent de temps en temps
aa_line = Associative Array();
aa_line["Dentist"] = {"Yellow", "Dotted"};
aa_line["Doctor"] = {"Green", "DashDotDot"};
aa_line["Engineer"] = {"Red", "Solid"};
Re : Boucle de style de ligne bivariéeAprès avoir créé votre rapport bivarié, recherchez les références aux segments de ligne en utilisant XPath ou Rechercher des segments, puis effectuez une action sur ces références :
Names Default To Here(1);
dt = Current Data Table();
biv = dt << Bivariate(Y(:weight), X(:height), Group By(:occupation), <<FIT line=""></FIT>
Re : Boucle de style de ligne bivariéeVoici une autre approche du même problème
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] || "\!" )} ) )"
)
)
);