Hi all,
I am trying to create bivariate plots with a fit spline. However, I am trying to get the line legends but with no success. How can I get and save the line legend? Please help
Here's my function
bivplot_mrw = Function({ ycol }, {plot},
biv = Bivariate( Y( Column(dt, ycol) ), X( Column( dt, mrwname ) ), Group By( Column( dt, grpname2 ) ),
Fit Spline( 1000 ) );
rbiv = biv << report << Show Points( 0 );
ylist = {};
For(g2 = 1, g2 <= Nitems(grplist2[1]), g2++,
Try(
curvename = rbiv[Outline Box( g2 + 1 )] << Get Title;
//Compute max and min per spline fit line to get y-axis max and min
current_row = storows2[ Contains( stolist2, grplist2[3][g2] ) ]; //Get the stolist rows for grplist2[g2]
current_row << Intersect( grprows[ Contains( grplist, grplist2[2][g2] ) ]);
current_row = Matrix( current_row << Get Keys );
xin = Column( dt, mrwname)[current_row];
yin = Column( dt, ycol)[current_row];
Try(ypred = Spline Eval( xin, Spline Coef( xin, yin, 1000 ) ));
ylist = Concat(ylist, As List(ypred));
//Adjust also the line style
If(
Contains( curvename, linestyle["ddd"] ),
biv << (Curve[g2] << Line Style( DashDotDot )),
Contains( curvename, linestyle["dash"] ),
biv << (Curve[g2] << Line Style( Dashed ))
);
));
Try( paxis = axiscalc( Min(ylist), Max(ylist) ), Show("axiscalc error for "||ycol) );
Try( xaxis = axiscalc( mrwmin, mrwmax ), Show("axiscalc error for MRW") );
rbiv[Frame Box( 1 )] << {Frame Size( 205, 164 ), Marker Size( 1 ), Line Width Scale( 2 )};
Try( rbiv[Axis Box( 1 )] << Max( paxis["Max"] ) << Min( paxis["Min"] ) << Inc( paxis["Inc"] ) << Minor Ticks( paxis["Ntick"] ) );
Try( rbiv[Axis Box( 2 )] << Max( xaxis["Max"] ) << Min( xaxis["Min"] ) << Inc( xaxis["Inc"] ) << Minor Ticks( xaxis["Ntick"] ) );
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 << xpath( "//OutlineBox" )) << Close;
rbiv[Outline Box( 1 )] << Set Title( ycol );
rbiv[Border Box( 2 )] << Delete Box;
rbiv[Outline Box( 1 )] << Open All Like This;
);