Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Reverse continuous group Y variable of graph builder

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Nov 3, 2017 2:06 PM
(2665 views)

Usually, we can reverse the X and Y axis in the axis settings -> Reverse order. However, it does not work for "Group" variable, especially of continuous type.

Here is an example

```
Names Default To Here( 1 );
dt=Open( "$SAMPLE_DATA/Big Class.jmp" );
// Method 1 ... didn't work
// Column(dt, "weight")<<Set Property( "Axis", {Reversed Scale} );
// Method 2 ... didn't work
// List=sort descending(as list(Column(dt, "weight")<<get values))
// Column(dt, "weight")<<Set Property( "Value Ordering", List);
//Plot
Graph Builder(
Size( 564, 540 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( :height ), Group Y( :weight, levels(3) ) ),
Elements( Points( X, Y, Legend( 2 ) ) ),
);
```

The "Weight" variable ploted interval of small values on the top and large values in the bottom, but it make more sense to me if the large one be placed on the top like Y-axis. Two different methods have been applied, but all of them didn't work in my case.

Method 1:

Set the column property "Axis" in reverse order

Method 2:

Set the column property "Value Ordering" in reverse order. In this way, JMP treated the continuous variable as discrete variable in the graph which is not the desired plot.

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

The approach I took to solve this problem is to create a new column that has a reversed value and then it applies a Value Label to label the groupings correctly.

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Method 1 ... didn't work
// Column(dt, "weight")<<Set Property( "Axis", {Reversed Scale} );
// Method 2 ... didn't work
// List=sort descending(as list(Column(dt, "weight")<<get values))
// Column(dt, "weight")<<Set Property( "Value Ordering", List);
dt << New Column( "New Weight",
ordinal,
formula(
If(
:weight <= Floor( Col Quantile( :weight, .333 ) + 1 ), 3,
:Weight <= Floor( Col Quantile( :weight, .666 ) + 1 ), 2,
1
)
)
);
Eval(
Substitute(
Expr(
dt:new weight << set property( "value labels", {3 = _3_, 2 = _2_, 1 = _1_} )
),
Expr( _3_ ),
Char( Min( dt:weight[dt << get rows where( :New Weight == 3 )] ) ) || "-" ||
Char( Max( dt:weight[dt << get rows where( :New Weight == 3 )] ) ),
Expr( _2_ ),
Char( Max( dt:weight[dt << get rows where( :New Weight == 3 )] ) ) || "-" ||
Char( Max( dt:weight[dt << get rows where( :New Weight == 2 )] ) ),
Expr( _1_ ),
Char( Max( dt:weight[dt << get rows where( :New Weight == 2 )] ) ) || "-" ||
Char( Max( dt:weight[dt << get rows where( :New Weight == 1 )] ) )
)
);
//Plot
Graph Builder(
Size( 564, 540 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( :height ), Group Y( :New Weight, levels( 3 ) ) ),
Elements( Points( X, Y, Legend( 2 ) ) ),
);
```

The code is pretty basic, but will work for data where you want it grouped into 3 bins. It could be expanded to allow for any number of levels.

Jim

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

The approach I took to solve this problem is to create a new column that has a reversed value and then it applies a Value Label to label the groupings correctly.

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Method 1 ... didn't work
// Column(dt, "weight")<<Set Property( "Axis", {Reversed Scale} );
// Method 2 ... didn't work
// List=sort descending(as list(Column(dt, "weight")<<get values))
// Column(dt, "weight")<<Set Property( "Value Ordering", List);
dt << New Column( "New Weight",
ordinal,
formula(
If(
:weight <= Floor( Col Quantile( :weight, .333 ) + 1 ), 3,
:Weight <= Floor( Col Quantile( :weight, .666 ) + 1 ), 2,
1
)
)
);
Eval(
Substitute(
Expr(
dt:new weight << set property( "value labels", {3 = _3_, 2 = _2_, 1 = _1_} )
),
Expr( _3_ ),
Char( Min( dt:weight[dt << get rows where( :New Weight == 3 )] ) ) || "-" ||
Char( Max( dt:weight[dt << get rows where( :New Weight == 3 )] ) ),
Expr( _2_ ),
Char( Max( dt:weight[dt << get rows where( :New Weight == 3 )] ) ) || "-" ||
Char( Max( dt:weight[dt << get rows where( :New Weight == 2 )] ) ),
Expr( _1_ ),
Char( Max( dt:weight[dt << get rows where( :New Weight == 2 )] ) ) || "-" ||
Char( Max( dt:weight[dt << get rows where( :New Weight == 1 )] ) )
)
);
//Plot
Graph Builder(
Size( 564, 540 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( :height ), Group Y( :New Weight, levels( 3 ) ) ),
Elements( Points( X, Y, Legend( 2 ) ) ),
);
```

The code is pretty basic, but will work for data where you want it grouped into 3 bins. It could be expanded to allow for any number of levels.

Jim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Reverse continuous group Y variable of graph builder

Hi Jim, thanks so much for the help. that's really helpful and exactly what I need.