Treemap
Example 1
Summary: Visualizes a treemap representation of data by State, colored by 2004 Verbal scores and sized by % Taking (2004), using the Open data table feature in JMP.
Code:
// Treemap
// Open data table
dt = Open("data_table.jmp");
// Treemap
Treemap(
Categories( :State ),
Coloring( :"2004 Verbal"n ),
Sizes( :"% Taking (2004)"n ),
Ordering( :X, :Y )
);
Code Explanation:
- Open data table;
- Create treemap visualization.
- Set categories by State.
- Color by 2004 Verbal scores.
- Size by % Taking (2004).
- Order by X and Y.
Example 2
Summary: Vizualizes electoral data by state, using Treemap to display Winner, Electors, and Mean(X) and Mean(Y) values, with a JMP Default color theme.
Code:
dt under test = Open("data_table.jmp");
obj = Treemap(
Categories( :State ),
Coloring( :Winner ),
Sizes( :Electors ),
Ordering( :Name( "Mean(X)" ), :Name( "Mean(Y)" ) ),
Color Theme( "JMP Default" )
);
Code Explanation:
- Open data_table data
- Create Treemap object.
- Set categories to State.
- Color by Winner.
- Size by Electors.
- Order by Mean(X).
- Order by Mean(Y).
- Use JMP Default color theme.
Example 3
Summary: Creates a treemap visualization to display data by State, colored by 2004 Verbal and sized by % Taking (2004), with ordering based on X and Y.
Code:
dt under test = Open("data_table.jmp");
obj = Treemap( Categories( :State ), Coloring( :Name( "2004 Verbal" ) ), Sizes( :Name( "% Taking (2004)" ) ), Ordering( :X, :Y ) );
Code Explanation:
- Open table.
- Create treemap object.
- Set categories to State.
- Color by 2004 Verbal.
- Size by % Taking (2004).
- Order by X and Y.
Example 4
Summary: Creates a treemap visualization to display city-level data, colored by ozone levels and sized by population.
Code:
Open("data_table.jmp");
Treemap( Categories( :city ), Coloring( :OZONE ), Sizes( :POP ) );
Code Explanation:
- Open data table;
- Create treemap visualization.
- Set categories to city.
- Color by ozone levels.
- Size by population.
Example 5
Summary: Creates and analyzes a treemap visualization to explore city-level data, setting missing value codes and generating a report with journal extraction.
Code:
dt = Open("data_table.jmp");
obj = Treemap( Categories( :city ), Coloring( :OZONE ), Sizes( :POP ) );
:city << Set Property( "Missing Value Codes", "ALBANY" );
obj2 = obj << Redo Analysis;
rpt = obj2 << Report;
expr = rpt << Get Journal;
p = "ALBANY";
ans = Pat Match( expr, p );
Code Explanation:
- Open data table;
- Create treemap object.
- Set missing value code for city.
- Redo analysis with updated settings.
- Generate report from analysis.
- Extract journal from report.
- Define pattern to search for.
- Search for pattern in journal.
- Store search result in ans variable.
Example 6
Summary: Creates a Treemap visualization to analyze data by city, state, and region, utilizing transformed columns for coloring, sizing, and ordering.
Code:
dt = Open("data_table.jmp");
Treemap(
Categories( Transform Column( "Concatenate[city,State]", Character, Formula( :city || ", " || :State ) ) ),
Coloring( Transform Column( "OZONE^2", Formula( :OZONE * :OZONE ) ) ),
Sizes( Transform Column( "POP^2", Formula( :POP * :POP ) ) ),
Ordering( Transform Column( "Max deg. F Jan^3", Formula( :Max deg. F Jan ^ 3 ) ) ),
Tile( 0 ),
By( Transform Column( "Last[Region]", Character, Formula( Word( -1, :Region ) ) ) )
);
Close( dt, nosave );
exlog = "While processing sex=M the following error(s) occurred: No multivariate correlations due to all rows missing";
Code Explanation:
- Open data table.
- Create concatenated city and state column.
- Create squared OZONE column.
- Create squared POP column.
- Create cubed Max deg. F Jan column.
- Create last word from Region column.
- Generate Treemap visualization.
- Close data table without saving.
- Log error message for sex=M.
Example 7
Summary: Creates a treemap visualization to explore relationships between city, state, ozone levels, population sizes, and max January degrees Fahrenheit.
Code:
dt = Open("data_table.jmp");
Treemap(
Categories( Transform Column( "Concatenate[city,State]", Character, Formula( :city || ", " || :State ) ) ),
Coloring( Transform Column( "OZONE^2", Formula( :OZONE * :OZONE ) ) ),
Sizes( Transform Column( "POP^2", Formula( :POP * :POP ) ) ),
Ordering( Transform Column( "Max deg. F Jan^3", Formula( :Max deg. F Jan ^ 3 ) ) ),
Tile( 0 ),
By( Transform Column( "Last[Region]", Character, Formula( Word( -1, :Region ) ) ) )
);
Code Explanation:
- Open data table;
- Create treemap visualization.
- Concatenate city and state.
- Calculate squared ozone levels.
- Calculate squared population sizes.
- Calculate cubed max January degrees Fahrenheit.
- Set tile option to 0.
- Group by last region word.
Treemap using Expr
Example 1
Summary: Create and execute two treemap scripts from a data table, filtering rows by height and selecting categories based on age.
Code:
dt = Open("data_table.jmp");
dt << row selection( select where( :height == 60 ), current selection( "clear" ) );
tmJSL = Expr(
dt << Treemap( Categories( :age ), Sizes( :weight ) )
);
tmJSL1 = Expr(
Treemap( Categories( :age ) )
);
Code Explanation:
- Open data table.
- Select rows where height is 60.
- Clear current selections.
- Define treemap script.
- Define another treemap script.
- Execute first treemap script.
- Execute second treemap script.
Example 2
Summary: Creates a treemap visualization with proportional selection, combining two expressions for age categories and weight sizes.
Code:
dt = Open("data_table.jmp");
dt << row selection( select where( :height == 60 ), current selection( "clear" ) );
tmJSL = Expr(
dt << Treemap( Categories( :age ), Sizes( :weight ) )
);
tmJSL1 = Expr(
Treemap( Categories( :age ) )
);
New Window( "combined treemap for proportional selection", Outline Box( "test", V List Box( Eval( tmJSL ), Eval( tmJSL1 ) ) ) );
Code Explanation:
- Open data table.
- Select rows where height is 60.
- Clear current selections.
- Define treemap expression with age categories and weight sizes.
- Define treemap expression with age categories only.
- Create new window for combined treemap.
- Add outline box titled "test".
- Add vertical list box to window.
- Evaluate first treemap expression.
- Evaluate second treemap expression.
TreeMap
Summary: Creates a treemap report with color themes based on population data, using JMP's TreeMap platform.
Code:
dt = Open("data_table.jmp");
obj = TreeMap( Categories( :city ), Coloring( :POP ) );
For( i = 0, i <= 9, i++,
obj << color theme( i )
);
obj << Color theme( Green to black to red );
rpt = obj << report;
Code Explanation:
- Open data table.
- Create treemap object.
- Set categories to city.
- Set coloring to population.
- Loop through color themes.
- Apply each color theme.
- Set final color theme.
- Generate report.