<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hello everyone,
I was doing a really simple bar chart in graph builder and i found our that you cannot get a correct order (ascending/descending) if you subset the bar charts by third variable. By use the example provided by JMP (57555 - How to specify ascending or descending order of bars in a bar chart), I understand how to create a bar chart with Age as X and height as Y and use height value to order your bar. However, if I want to add third variable, say sex into the bar chart as X group, then the order (ascending/descending) seems not working properly for each gender group.


I thought this should be a very common and a lot of people have done similar plots. I am not sure if I missed something? Hope someone could give me some suggestions.
Thank you,
Tao
Hi Jerry,
I think this is exactly what I am looking for and I didn't realize that I could use a new column for the ordering.
Thank you for your help!
Tao
Hi Tao,
Try this and see if it does what you need (still using the Big Class as an example):
- Create a new formula column to aggregate Height by Sex and Age: Col Mean(height, sex, age)
- Change the modeling type of the new column to Ordinal (or Nominal)
- Create the graph as you did in your original post
- Now drop the new column on the x-axis between sex and age

Change the axis by double clicking and turning off all marks and labels for Label Row 2, you can also select Reverse Order:

If you don't want the Reverse Order to affect the sex label as well, you can assign a Value Order property to the formula column and select Reverse from there.
Hope this helps.
Like this? Just put Sex as an overlay, not group.

Hi Jim,
Thank you for your suggestion and I think wiring scripts directly would be easier for me.The reason why I asked my question is I created a bar chart in R and there are five types of things and they are plotted against the coefficient values and also separated by time (1,3,5,...,20). The order of bars in each time point is descending by their absolute values and each bar chart at different times are next to each in order to check the trends. I tried to do the same thing in JMP but didn't figure out a way to do it.
Tao

There are a few different ways that this can be accomplished. The most direct way to do this would be to create 2 subsets of the data, dividing the males and females into separate data tables, then plotting them independently, and putting them back together into a new display window.
Here is a script that automates the process, but it can be done interactively as well
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << select where( :sex == "M" );
dtM = dt << Subset(
,selected rows(1),
Selected columns only( 0 )
);
dt << select where( :sex == "F" );
dtF = dt << Subset(
Selected Rows( 1 ),
Selected columns only( 0 )
);
New Window( "Graphs",
Lineup Box( N Col( 2 ), spacing( 0 ),
dtF << Graph Builder(
Size( 533, 447 ),
Show Control Panel( 0 ),
Variables( X( :age, Order By( :height, Descending, Order Statistic( "Mean" ) ) ), Y( :height ) ),
Elements( Bar( X, Y, Legend( 4 ) ) )
),
dtM << Graph Builder(
Size( 533, 447 ),
Show Control Panel( 0 ),
Variables( X( :age, Order By( :height, Descending, Order Statistic( "Mean" ) ) ), Y( :height ) ),
Elements( Bar( X, Y, Legend( 4 ) ) )
)
)
);

Hi Jim,
Thank you for your comment! But I wonder if there is a way I can sort the bar for each group though?
Tao
The option is working correctly. It does not reorder the axis independently for the groups. The order displayed is for the overall descending order.