For example, I have 3 column:
Name Age Score:
Jason 21 98
Alice 19 67
Dave 36 89
John 28 70
I would like to plot x: Name and Y: Score, but I also want to sort X axis (names) by their Age.
Thanks so much for the help!
When using Graph Builder, all that has to be done, is to drag the variable you want to order your axis by, to the Order By area for the Axis, as shown below
Or you can sort the data table by the sort variable(Age), and then set the Column Property, Row Order Levels for the column Name, and then the order used for the Name variable axis will be the order the Names are found in the data table.
When using Graph Builder, all that has to be done, is to drag the variable you want to order your axis by, to the Order By area for the Axis, as shown below
Or you can sort the data table by the sort variable(Age), and then set the Column Property, Row Order Levels for the column Name, and then the order used for the Name variable axis will be the order the Names are found in the data table.
Thanks! It works!
I think the column property "Value Ordering" is what you need. It can be set manually using the column dialog or with jsl (example below).
// Example Table
New Table("test",
Add Rows(4),
New Column("Name",
Character,
Set Values({"Jason", "Alice", "Dave", "John"})
),
New Column("Age",
Set Values([21, 19, 36, 28])
),
New Column("Score:",
Set Values([98, 67, 89, 70])
)
);
// Plot Score by Age
Oneway(Y(:Name("Score:")), X(:Name));
// Set value ordering to Name after mean Age
Summarize( g = by( :Name ), m = Mean( :Age ) );
:Name << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );
// Plot again!
Oneway(Y(:Name("Score:")), X(:Name));
Hi Guys,
Any idea how I can use ms suggestion by group?
for the above example, let's say I like to chart the oneway by gander.
I can do this with graph builder but I like to use the Variability Chart.
Oneway(Y(:Name("Score:")), X(:Name), By(:Name("Gander"));
//With Graph Builder
Graph Builder(
Size( 800, 500),
Variables(
X( :name, Order By( :age, Ascending, Order Statistic( "Mean" ) ),
....
Group X( :Gender, N View Levels( 2 ), First View Level( 2 ) ),
...
Not sure I understand what you need, but the same approach can be used for Variability Chart. If grouped by an additional variable, the value ordering should be correctly applied within each group.
Here's an example based on the Big Class example table:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Set value ordering to :name after mean :age
Summarize( g = by( :name ), m = Mean( :age ) );
:Name << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );
// Variability chart with names grouped by sex ordered after age
Variability Chart(Y(:height), X(:sex, :name));
Sorry, the Sex group example is not so good since it has few (or no) similar names on each group.
here is the same example based on the semiconductor table:
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
// Set value ordering to :name after mean :age
Summarize( g = by( :lot_id ), m = Mean( :PNP1 ) );
:lot_id << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );
// Variability chart with names grouped by sex ordered after age
Variability Chart(Y(:NPN1), X(:SITE, :lot_id));
it results with the below Var chart (all SITE has same lot_id order) - which is wrong I believe.
How can I plot the lot_id order by PNP1 for every SITE in Var chart using jsl.
Hope I made my request clearer.
I prefer using
Variability Chart(Y(:NPN1), X(:SITE), By (:lot_id));
and not
Variability Chart(Y(:NPN1), X(:SITE, :lot_id));
Also, the statement that I can do this using graph builder from my previous replay here is wrong, I see that now.
Thank you.
I think creating a concat column will do the trick as follow
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
dt << New Column("lotID by Site", Character, Formula(char(:SITE)||"_"||:lot_id) );
// Set value ordering to :name after mean :age
Summarize( g = by( :Name("lotID by Site") ), m = Mean( :PNP1 ) );
:Name("lotID by Site") << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );
// Variability chart with names grouped by sex ordered after age
Variability Chart(Y(:NPN1), X(:Name("lotID by Site")), by (:SITE));
if anyone can share a more elegant solution I will appreciate it.