Script for setting all axis limits in a graph builder to values computed from the displayed dataIn order to speed up one step of a workflow, I am trying to write a script that automatically sets the axis limits of all Y axes in a graph builder to certain values (quantiles) that can be computed from the displayed data.
The plan was:
- Get the axis labels
- Compute the desired limits by using the corresponding columns in the data table
- Set the limits accordingly.
This turns out to be more complicated than expected in the first place, because a local data filter can be used, labels can be modified, etc.
So I would rather like to get the different Y values for each axis directly from the graph builder. How to get the values from specific axes?
E.g. If I have
R = Current Report();
AB = R[axisbox(2)] ;
ab_min = -100; // How to access the value list containing all the values that are used by default to compute axis limits of AB here?
ab_max = 100;
AB << Min(ab_min);
AB << Max(ab_max);
By using "the cross" I ended up with some FrameBoxes, but I could not figure out how to get values from them.
Any ideas or better way how to do it?
Thanks Robbb
Mass CustomizationRe: Script for setting all axis limits in a graph builder to values computed from the displayed dataSomething like this should get you the marker values
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(570, 1049),
Show Control Panel(0),
Variables(
X(:age),
Y(:height),
Page(:sex)
)
);
frame = Report(gb)[FrameBox(1)];
frames = Report(gb) << XPath("//FrameBox");
marker_segs = (frames << Find Seg(Marker Seg(1)));
xm = marker_segs << Get X Values;
ym = marker_segs << Get Y Values;
show(xm, ym);
exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon
How to get Legend Box information, like color and marker type
Re: Script for setting all axis limits in a graph builder to values computed from the displayed dataCurrently I do not see a reliable way to get the column or column name that is plotted on an axis from the graph builder. The only way I can think of is getting the axis label, but this may have been modified by the user so that the text is not the column name any more. Furthermore, columns can be transformed/modified directly in the graph builder. If such a column is plotted on an axis, I would not be able to find that column in the data table at all. And yes, If I found the correct column in the data table, I would have to apply the filter settings from the local data filter.
If I could get the plotted data values directly back from the axis/graph builder somehow, it would be unimportant which kind of column is plotted, which filter is applied, which labels the user changed and what else could possibly go wrong and break my script.
Re: Script for setting all axis limits in a graph builder to values computed from the displayed dataWhy would it not work for you to just get the values from the data table? If rows have been excluded from the analysis, or if a Local Data Filter has been applied, then one would have to just apply those conditions.
names default to here(1);
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(570, 1049),
Show Control Panel(0),
Variables(
X(:age),
Y(:height),
Page(:sex)
)
);
allHeights = dt:height << get values;
// or if you want just the unique values of the column height, this
// is my prefered way to get them
uniqueHeights = associative array(dt:height<<GET values=""> </GET>
Re: Script for setting all axis limits in a graph builder to values computed from the displayed dataHi @jthi, hi @txnelson
thanks, but I think we have a little misunderstanding.
I do not want to get the current min and max from all y axes. I would like to get all corresponding y values of the displayed data in order to compute more appropriate limits.
For example, if for a y axis 1000 values are displayed, I would like to get a list or vector of those 1000 y values.
Re: Script for setting all axis limits in a graph builder to values computed from the displayed dataThe following JSL will return a list of all of the AxisBox()s for the current report. Both AxisBox(1) and AxisBox(2). So what can be done is to process entries, 2, 4, 6 etc. to access all of the AxisBox(2)s
r=current report();
yMaxs = ((r[1]<<TOP parent=""></TOP>
Re: Script for setting all axis limits in a graph builder to values computed from the displayed dataWould something like this work? Use XPath to get all axisboxes and then figure out which are Y-axis. After that you should be able to manipulate them
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(570, 1049),
Show Control Panel(0),
Variables(
X(:age),
Y(:height),
Page(:sex)
)
);
axisboxes = Report(gb) << XPath("//AxisBox");
/*y-axis seems to be even numbers*/
yaxis = axisboxes[2::N Items(axisboxes)::2];
ymin = yaxis << get min;
ymax = yaxis << get max;
show(ymin, ymax);