cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
tyang13
Level I

Ascending/Descending order of Bar Chart created in Graph builder does not work???

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.

11006_pastedImage_3.png

11007_pastedImage_4.png

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

1 ACCEPTED SOLUTION

Accepted Solutions
jerry_cooper
Staff (Retired)

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

Hi Tao,

Try this and see if it does what you need (still using the Big Class as an example):

  1. Create a new formula column to aggregate Height by Sex and Age: Col Mean(height, sex, age)
  2. Change the modeling type of the new column to Ordinal (or Nominal)
  3. Create the graph as you did in your original post
  4. Now drop the new column on the x-axis between sex and age

11041_Graph Builder2.jpg

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

11042_Graph Builder3.jpg

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.

View solution in original post

7 REPLIES 7
txnelson
Super User

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

The option is working correctly.  It does not reorder the axis independently for the groups.  The order displayed is for the overall descending order.

Jim
tyang13
Level I

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

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

txnelson
Super User

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

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 ) ) )

              )

       )

);

  11009_pastedImage_0.png

Jim
tyang13
Level I

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

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

11008_pastedImage_0.png

msharp
Super User (Alumni)

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

Like this? Just put Sex as an overlay, not group.

11013_pastedImage_0.png

jerry_cooper
Staff (Retired)

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

Hi Tao,

Try this and see if it does what you need (still using the Big Class as an example):

  1. Create a new formula column to aggregate Height by Sex and Age: Col Mean(height, sex, age)
  2. Change the modeling type of the new column to Ordinal (or Nominal)
  3. Create the graph as you did in your original post
  4. Now drop the new column on the x-axis between sex and age

11041_Graph Builder2.jpg

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

11042_Graph Builder3.jpg

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.

tyang13
Level I

Re: Ascending/Descending order of Bar Chart created in Graph builder does not work???

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