Format
Format using Pref
Summary: Sets summary graph preferences, defines default name scope, creates a new project, and runs a script within the project to open a data table, set missing value codes for 'Item Number', and format the 'order date' column.
Code:
Pref( Show summary graphs below column names( 1 ) );
Names Default To Here( 1 );
project = New Project();
project << Run Script(
dt1 = Open("data_table.jmp");
dt1:Name( "Item Number" ) << {Set Property( "Missing Value Codes", {1001, 1002, 1003, 1105, 1106} )};
dt1:order date << Data Type( "Numeric", Format( ":day:hr:m:s", 17, 0 ), Input Format( "m/d/y" ) );
dt1:order date << Data Type( "Numeric", Format( "ddMonyyyy", 22 ), Input Format( "m/d/y" ) );
);
Code Explanation:
- Set summary graphs preference.
- Set default name scope.
- Create new project.
- Run script within project.
- Open data table;
- Define missing value codes for "Item Number".
- Set "order date" data type to numeric.
- Format "order date" as day, hour, minute, second.
- Set "order date" input format as month/day/year.
- Format "order date" as dayMonthYear.
Format using Chart
Example 1
Summary: Creates a line chart to visualize mean height and weight by age and sex, with formatted Y-axis labels.
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Chart( X( :Age, :sex ), Y( Mean( :Height ), Mean( :Weight ) ), Overlay( 1 ) );
obj << Line Chart( 1 );
obj << Label by Value;
obj << Show Labels;
obj << (Y[1] << Label Format( 9, 2 ));
Code Explanation:
- Set default names.
- Open data_table data
- Create chart object.
- Add line chart.
- Label by value.
- Show labels.
- Format Y-axis label.
Example 2
Summary: Creates and analyzes a bar chart to summarize age distribution by sex, utilizing overlay axes for detailed visualization.
Code:
dt = Open("data_table.jmp");
obj = Chart(
X( :sex ),
Y( Sum( :age ) ),
Overlay Axis << {{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 6000 ), Inc( 1000 ), Minor Ticks( 1 )}},
Overlay Stack Axis << {{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 12000 ), Inc( 2000 ), Minor Ticks( 1 )}},
Bar Chart( 1 )
);
:age << Set Property( "Missing Value Codes", 26 );
obj2 = obj << Redo Analysis;
rpt2 = obj2 << Report;
expr2 = rpt2 << Get Journal;
p = "3959";
ans = Pat Match( expr2, p );
Code Explanation:
- Open data table;
- Create chart object.
- Set X axis to sex.
- Set Y axis to sum of age.
- Format overlay axis.
- Format overlay stack axis.
- Add bar chart.
- Set missing value code for age.
- Redo analysis on chart.
- Retrieve report from redo analysis.
Example 3
Summary: Creates a pie chart with customized overlay axes and level colors from a data table, utilizing JMP's Chart platform.
Code:
Open("data_table.jmp");
obj = Chart(
X( :Size Co ),
Y( N( N ) ),
Pie( 1 ),
Category Axis << {Label( None )},
Overlay Axis << {{Format( "Fixed Dec", 12, 1 ), Min( 5 ), Max( 20 ), Inc( 2.5 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )}},
Overlay Stack Axis << {{Min( -10 ), Max( 40 ), Inc( 10 ), Minor Ticks( 1 ), Rotated Labels( "Horizontal" )}},
Level[1] << Colors( 73 )
);
Code Explanation:
- Open data table;
- Create chart object.
- Set X-axis variable.
- Set Y-axis variable.
- Add pie chart type.
- Hide category axis labels.
- Format overlay axis.
- Format overlay stack axis.
- Set level colors.
Example 4
Summary: Creates a pie chart with customized overlay axes, utilizing the Chart() function in JMP.
Code:
dt = Open("data_table.jmp");
obj = Chart(
X( :Size Co ),
Y( N( N ) ),
Pie( 1 ),
Category Axis << {Label( None )},
Overlay Axis << {{Format( "Fixed Dec", 12, 1 ), Min( 5 ), Max( 20 ), Inc( 2.5 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )}},
Overlay Stack Axis << {{Min( -10 ), Max( 40 ), Inc( 10 ), Minor Ticks( 1 ), Rotated Labels( "Horizontal" )}},
Level[1] << Colors( 73 )
);
Code Explanation:
- Open data table;
- Create a chart object.
- Set X-axis to Size Co.
- Set Y-axis to N(N).
- Add pie chart element.
- Hide category axis labels.
- Format overlay axis.
- Format overlay stack axis.
- Set level 1 colors to 73.
Summary: Opens a data table and configures the Pred Formula HARDNESS with scientific notation, adjusting decimal places to 6 and then 5.
Code:
Open("data_table.jmp");
:Pred Formula HARDNESS << Format( "Scientific", 6 );
:Pred Formula HARDNESS << Format( "Scientific", 5 );
Code Explanation:
- Open data table;
- Set format for Pred Formula HARDNESS.
- Change format to Scientific.
- Set decimal places to 6.
- Change format to Scientific.
- Set decimal places to 5.