cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
Georg
Level VII

Draw reference lines for ordinal/nominal axis

Dear Community,

I'm struggling a bit with drawing reference lines on an ordinal axis. There are great examples on how to draw reference lines on continuous axes, but it seems to be different for ordinal axes. So in the example below I cannot tell JMP to draw a reference line at age of 13, instead I need to find the position at the axis in the GraphBuilder (that is two: 13 is the second age value when ordering from low to high) and set the reference line for that position. So far ok.

But I want to draw reference lines on many Graph Builder objects, that itself have local data filters, and thus have the same year e.g. 13 at different positions. You can try, if you exclude age=12 by local data filter, the the reference line is at the wrong position.

So a better strategy would be for me to be able to get the values from the x-axis of the Graph Builder object, so I could correctly add a reference line at age=13 for each Graph Builder.

In my real world example I have to set the reference line for each GraphBuilder in a dashboard with different filters at current calender week, that is given in a format of "YYYYWW".

JMP16 / Pro on Win10.

Any ideas? Thanks in advance

 

Names Default To Here( 1 );
// test reference lines for ordinal/nominal axis

// Open table and make graph
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
gb_obj = dt << graph builder( Show Control Panel( 0 ), variables( x( :age ), y( :weight ) ), Elements( bar( X, Y ) ) );

// get location of certain ordinal or nominal value from data table
refpos="13";
Summarize( dt, age_lst = by( :age ) );
label = Loc( age_lst, refpos );

// apply reference lines at different positions
Report( gb_obj )[AxisBox( 1 )] << add ref line( Eval( label - 1 ), "Dotted", "Red", refpos, 3 );
Georg
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Draw reference lines for ordinal/nominal axis

You might have to do some calculations based on the filters Is there a method to get axis values from graph builder? 

-Jarmo

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Draw reference lines for ordinal/nominal axis

The actual axis values for your chart range from 0 to 3.  Open the Axis settings and you will see the values

txnelson_0-1661896333931.png

Therefore, to add a reference line on the chart, you need to convert to this scale.  Below is an Add Ref Line that works

Report( gb_obj )[AxisBox( 1 )] << add ref line( 1, "Dotted", Red, "Yes", 3 );

txnelson_1-1661896477488.png

 

 

 

Jim
Georg
Level VII

Re: Draw reference lines for ordinal/nominal axis

Thanks @txnelson, but it's Not my Problem to Set a reference line, this worked already in my above Script dynamically. My Problem is the scale Translation for many graph builder, with different data on x axis, when I want to Set a ref line at age 13 for All.
Georg
jthi
Super User

Re: Draw reference lines for ordinal/nominal axis

You might have to do some calculations based on the filters Is there a method to get axis values from graph builder? 

-Jarmo