All,
I need to modify my Scripted Graph Builder so that it sets various scales for each plot.
I have a table of the (simplified) form:
:date - just a date
:rawValue - some numeric value
:byVariable - several categorical values to separate :rawValues into groups
:rawMedian - just a median value for each of the groups, formula Col Quantile(:rawValue, 0.5, :byVariable)
I plot it this way:
Graph Builder(
Size( 800, 500 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables(
X( :date ),
Y( :rawValue ),
Y( :rawMedian ) //It's just a straight horizontal line on each plot
),
By( :byVariable )
)
Now, I would like to set the Y axis scale for each plot separately, and be equal, let's say, 3*:rawMedian for that specific :byVariable.
What's the best way of doing this?
Thanks,
M.
Here is a simple example that is setting different values for each of the axes for the by groups. If you don't understand how the script is using the Display Trees to change the values, the Display Trees are documented in the Scripting Guide
Help==>Documentation Library
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/aircraft incidents.jmp" );
dt:Event Date << set name( "Date" );
dt:Total Uninjured << set name( "rawValue" );
dt:Engine Type << set name( "byVariable" );
dt << New Column( "rawMedian", formula( Col Quantile( :rawValue, .5, :byVariable ) ) );
gb = Graph Builder(
Size( 800, 500 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables(
X( :date ),
Y( :rawValue ),
Y( :rawMedian ) //It's just a straight horizontal line on each plot
),
By( :byVariable )
);
summarize(groups=by(:byVariable));
// loop across the different byVariable values and changes the axes
For(i=1,i<=nitems(groups), i++,
report(gb[i])[AxisBox(2)]<< max (14-i);
report(gb[i])[AxisBox(3)] << min (.6 +.01*i);
);