Mean
Mean using Tree Map
Summary: Visualizes a treemap to display the distribution of electoral votes across US states, using categories, coloring, sizes, and ordering to facilitate analysis.
Code:
// Treemap
// Open data table
dt = Open("data_table.jmp");
// Treemap
Tree Map(
Categories( :State ),
Coloring( :Winner ),
Sizes( :Electors ),
Ordering( :"Mean(X)"n, :"Mean(Y)"n ),
Color Theme( "JMP Default" )
);
Code Explanation:
- Open table.
- Create treemap.
- Set categories.
- Set coloring.
- Set sizes.
- Set ordering.
- Apply color theme.
Mean using Chart
Example 1
Summary: Creates a stacked bar chart to visualize sales data, with X-axis variables set to 'Type' and 'Size Co', and Y-axis variable set to the mean of 'Sales ($M)'
Code:
Open("data_table.jmp");
Chart( X( :Type, :Size Co ), Y( Mean( :Name( "Sales ($M)" ) ) ), Stack Bars( 1 ), Bar Chart( 1 ) );
Code Explanation:
- Open data table;
- Create chart object.
- Set X axis variables.
- Set Y axis variable.
- Apply stack bars option.
- Apply bar chart option.
Example 2
Summary: Creates a pie chart to visualize mean sales data, with X-axis set to 'Size Co' and Y-axis set to 'Mean(Sales ($M))', while hiding category labels.
Code:
Open("data_table.jmp");
Chart( X( :Size Co ), Y( Mean( :Name( "Sales ($M)" ) ) ), Pie( 1 ), Category Axis << {Label( None )} );
Code Explanation:
- Open data table;
- Create chart object.
- Set X-axis variable.
- Set Y-axis variable.
- Add pie chart element.
- Configure category axis.
- Hide category labels.
Example 3
Summary: Creates a line chart to visualize mean height and weight by age and sex, using overlay and labeling features.
Code:
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;
Code Explanation:
- Open data table;
- Create chart object.
- Set X variables: Age, sex.
- Set Y variables: Mean Height, Mean Weight.
- Enable overlay.
- Add line chart.
- Label by value.
- Show labels.
Example 4
Summary: Creates a chart object with X-axis variables 'Age' and 'sex', Y-axis variables 'Mean Height' and 'Mean Weight', utilizing JMP's Chart function.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Age, :sex ), Y( Mean( :Height ), Mean( :Weight ) ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variables.
- Calculate mean height.
- Calculate mean weight.
- Display chart.
Example 5
Summary: Creates a chart object with overlay effect, using data from an open JMP data table and specifying X variables (Age and sex) and Y variables (Mean Height and Mean Weight).
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Chart( X( :Age, :sex ), Y( Mean( :Height ), Mean( :Weight ) ) );
obj << Overlay( 1 );
Code Explanation:
- Set default name scope.
- Open data table.
- Create chart object.
- Set X variables: Age, sex.
- Set Y variables: Mean Height, Mean Weight.
- Apply overlay effect.
Example 6
Summary: Creates a range chart to visualize mean height and weight by age and sex, utilizing default names for data table and chart object.
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Chart( X( :Age, :sex ), Y( Mean( :Height ), Mean( :Weight ) ) );
obj << Range Chart( 1 );
Code Explanation:
- Set default names.
- Open data table.
- Create chart object.
- Set X variables: Age, Sex.
- Set Y variables: Mean Height, Mean Weight.
- Apply range chart settings.
- Display chart.
Example 7
Summary: Creates a chart with X-axis variables Age and sex, Y-axis variables Mean Height and Mean Weight, and disables overlay option.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Age, :sex ), Y( Mean( :Height ), Mean( :Weight ) ), Overlay( 0 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variables.
- Disable overlay option.
Example 8
Summary: Creates a chart with separate axes, displaying mean Height and Weight by Age and sex.
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Chart( X( :Age, :sex ), Y( Mean( :Height ), Mean( :Weight ) ), Overlay( 0 ) );
obj << Show Separate Axes( 1 );
Code Explanation:
- Set default name scope.
- Open data table;
- Create chart object.
- Set X-axis to Age and sex.
- Set Y-axis to mean Height and Weight.
- Disable overlay.
- Display separate axes.
Example 9
Summary: Creates a stacked bar chart to visualize mean height and weight by age and sex, utilizing default naming conventions.
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Chart( X( :Age, :sex ), Y( Mean( :Height ), Mean( :Weight ) ) );
obj << Stack Bars( 1 );
Code Explanation:
- Set default names scope.
- Open data table.
- Create chart object.
- Set X-axis to Age and Sex.
- Set Y-axis to mean Height and Weight.
- Apply stack bars option.
Example 10
Summary: Creates a bar chart to visualize profits by type and size, using the Mean function to calculate profit values.
Code:
Open("data_table.jmp");
Chart( X( :Type, :Size Co ), Y( Mean( :Name( "Profits ($M)" ) ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variable.
- Apply bar chart style.
Example 11
Summary: Creates a bar chart to visualize mean height by age, with customizable colors for each level.
Code:
dt = Open("data_table.jmp");
obj = dt << Chart(
X( :age ),
Y( Mean( :height ) ),
Level[1] << Colors( 72 ),
Level[2] << Colors( 72 ),
Level[3] << Colors( 72 ),
Level[4] << Colors( 72 ),
Level[5] << Colors( 72 ),
Level[6] << Colors( 72 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Open data_table data
- Create chart object.
- Set X axis to age.
- Set Y axis to mean height.
- Set color for level 1.
- Set color for level 2.
- Set color for level 3.
- Set color for level 4.
- Set color for level 5.
- Set color for level 6.
- Generate bar chart.
- Create report object.
Example 12
Summary: Creates a bar chart to visualize mean blood pressure values at different time points, utilizing overlay colors for distinct groups.
Code:
dt = Open("data_table.jmp");
obj = Chart(
X( :Dose ),
Y( Mean( :BP 8M ), Mean( :BP 12M ), Mean( :BP 6M ), Mean( :BP 8W ) ),
y[1] << overlay color( 4 ),
y[2] << overlay color( 3 ),
y[3] << overlay color( 8 ),
y[4] << overlay color( 9 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Open data table;
- Create chart object.
- Set X-axis variable.
- Set Y-axis variables.
- Overlay color for first Y.
- Overlay color for second Y.
- Overlay color for third Y.
- Overlay color for fourth Y.
- Generate bar chart.
- Generate report.
Example 13
Summary: Creates and creates a report for a bar chart to visualize mean height by sex, with color-coded levels for age groups.
Code:
dt = Open("data_table.jmp");
obj = Chart(
Grouping( :sex ),
X( :age ),
Y( Mean( :height ) ),
Level[1] << Colors( 72 ),
Level[2] << Colors( 72 ),
Level[3] << Colors( 72 ),
Level[4] << Colors( 72 ),
Level[5] << Colors( 72 ),
Level[6] << Colors( 72 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Open data table;
- Create chart object.
- Group by sex variable.
- Set X-axis to age.
- Set Y-axis to mean height.
- Color level 1 bars.
- Color level 2 bars.
- Color level 3 bars.
- Color level 4 bars.
- Color level 5 bars.
- Color level 6 bars.
- Generate bar chart.
- Save chart report.
Example 14
Summary: Creates a bar chart to visualize sales and profits data, with customizable colors for each level.
Code:
dt = Open("data_table.jmp");
obj = Chart(
X( :Type, :Size Co ),
Y( Mean( :Name( "Sales ($M)" ) ), Mean( :Name( "Profits ($M)" ) ) ),
Overlay( 0 ),
Level[1] << Colors( 4 ),
Level[2] << Colors( 6 ),
Level[3] << Colors( 8 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variables.
- Disable overlay.
- Set level 1 colors.
- Set level 2 colors.
- Set level 3 colors.
- Configure bar chart.
- Generate report.
Example 15
Summary: Creates a bar chart to visualize mean height by age, using JMP's Chart platform.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :age ), Y( Mean( :height ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis to age.
- Set Y-axis to mean height.
- Use bar chart type.
Example 16
Summary: Creates a bar chart to visualize mean height and weight by sex and age, utilizing JMP's Chart() function.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :sex, :age ), Y( Mean( :height ), Mean( :weight ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variables.
- Calculate mean height.
- Calculate mean weight.
- Configure bar chart type.
- Display chart.
Example 17
Summary: Creates a bar chart to visualize mean height by sex, with age on the x-axis.
Code:
dt = Open("data_table.jmp");
obj = Chart( Grouping( :sex ), X( :age ), Y( Mean( :height ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data table;
- Create chart object.
- Group by sex.
- Set X-axis to age.
- Set Y-axis to mean height.
- Use bar chart type.
Example 18
Summary: Creates a bar chart to display mean age by marital status and country, with sex as the X-axis variable.
Code:
dt = Open("data_table.jmp");
obj = Chart( Grouping( :marital status, :country ), X( :sex ), Y( Mean( :age ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data_table data
- Create chart object.
- Set grouping variables.
- Set X-axis variable.
- Set Y-axis variable.
- Calculate mean age.
- Use bar chart type.
- Display chart.
Example 19
Summary: Creates a bar chart to visualize mean age by marital status and country, with sex and type as categorical variables.
Code:
dt = Open("data_table.jmp");
obj = Chart( Grouping( :marital status, :country ), X( :sex, :type ), Y( Mean( :age ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data table;
- Create a chart object.
- Set grouping variables: marital status, country.
- Set X-axis variables: sex, type.
- Set Y-axis variable: mean age.
- Configure bar chart style.
Example 20
Summary: Creates a bar chart to visualize mean height and weight by sex, using JMP's Chart platform.
Code:
dt = Open("data_table.jmp");
obj = Chart( Grouping( :sex ), X( :age ), Y( Mean( :height ), Mean( :weight ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Group by sex variable.
- Set X-axis to age.
- Calculate mean height.
- Calculate mean weight.
- Add mean height to Y-axis.
- Add mean weight to Y-axis.
- Display bar chart.
- Use first bar chart option.
Example 21
Summary: Creates a chart object with two mean values on the y-axis, using the Type column as the x-axis.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Type ), Y( Mean( :Name( "Sales($M)" ) ), Mean( :Name( "Assets($Mil.)" ) ) ) );
Code Explanation:
- Open data table;
- Create a chart object.
- Set X-axis to Type column.
- Add Mean of Sales($M) to Y-axis.
- Add Mean of Assets($Mil.) to Y-axis.
Example 22
Summary: Creates a bar chart to visualize mean sales and profits data, utilizing X-axis variables for type and size, and Y-axis variables for mean sales and profits.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Type, :Size Co ), Y( Mean( :Name( "Sales ($M)" ) ), Mean( :Name( "Profits ($M)" ) ) ), Bar Chart( 1 ) );
Code Explanation:
- Open data table;
- Assign data table to variable.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variables.
- Calculate mean for Sales.
- Calculate mean for Profits.
- Specify bar chart type.
- Display chart.
Example 23
Summary: Creates a bar chart to visualize sales and profits data, disabling overlay options and setting X-axis variables.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Type, :Size Co ), Y( Mean( :Name( "Sales ($M)" ) ), Mean( :Name( "Profits ($M)" ) ) ), Overlay( 0 ), Bar Chart( 1 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variables.
- Disable overlay option.
- Enable bar chart type.
- Display chart.
Example 24
Summary: Creates a stacked bar chart to visualize sales data, with X-axis variables set to Type and Size Co, and Y-axis variable set to the mean of Sales ($M).
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Type, :Size Co ), Y( Mean( :Name( "Sales ($M)" ) ) ), Stack Bars( 1 ), Bar Chart( 1 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X axis variables.
- Set Y axis variable.
- Apply stack bars option.
- Apply bar chart option.
Example 25
Summary: Creates a chart with mean height and weight by sex and age, enabling overlay and displaying the level legend.
Code:
Open("data_table.jmp");
obj = Chart( X( :sex, :age ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Show Level Legend( 1 );
Code Explanation:
- Open data table.
- Create chart object.
- Set X variables: sex, age.
- Set Y variables: mean height, mean weight.
- Enable overlay.
- Show level legend.
Example 26
Summary: Creates a chart with mean height and weight by age and sex, displaying level legend.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Show Level Legend( 1 );
Code Explanation:
- Open data table;
- Create chart object.
- Set X variables: age, sex.
- Set Y variables: mean height, mean weight.
- Enable overlay.
- Display level legend.
Example 27
Summary: Creates a chart with mean height as the y-axis and sex and age as categorical variables, displaying a level legend.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :sex, :age ), Y( Mean( :height ) ) );
obj << Show Level Legend( 1 );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variable.
- Calculate mean height.
- Display level legend.
Example 28
Summary: Creates a chart with mean height and weight by age and sex, enabling overlay color for the first Y variable.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Y[1] << Overlay Color( 41 );
Code Explanation:
- Open data table;
- Create chart object.
- Set X variables: age, sex.
- Set Y variables: mean height, mean weight.
- Enable overlay.
- Apply overlay color to first Y variable.
Example 29
Summary: Creates a chart with two Y-axis variables, enabling overlay and customizing color for the second axis.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Y[2] << Overlay Color( Red );
Code Explanation:
- Open data table;
- Create chart object.
- Set X-axis variables.
- Set Y-axis variables.
- Enable overlay.
- Access second Y-axis.
- Change overlay color to red.
Example 30
Summary: Creates a chart object with X variables age and sex, Y variables mean height and mean weight, and applies overlay to Y variables while changing the color of the first Y overlay to 41.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << (Y[1] << Overlay Color( 41 ));
Code Explanation:
- Open data_table data
- Create a chart object.
- Set X variables: age, sex.
- Set Y variables: mean height, mean weight.
- Apply overlay to Y variables.
- Change color of first Y overlay to 41.
Example 31
Summary: Creates a chart with two overlaid Y-axes, displaying mean height and weight by age and sex, with the second Y-axis colored red.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << (Y[2] << Overlay Color( Red ));
Code Explanation:
- Open data table;
- Create a chart object.
- Set X-axis to age and sex.
- Set Y-axis to mean height and weight.
- Overlay the charts.
- Change the second Y-axis overlay color to red.
Example 32
Summary: Creates a chart object with two overlays, displaying mean height and mean weight by age and sex.
Code:
dt = Open("data_table.jmp");
obj = Chart(
X( :age, :sex ),
Y( Mean( :height ), Mean( :weight ) ),
Overlay( 1 ),
Y[1] << Overlay Color( 41 ),
Y[2] << Overlay Color( Red )
);
Code Explanation:
- Open data table.
- Create chart object.
- Set X variables: age, sex.
- Set Y variables: mean height, mean weight.
- Enable overlay.
- Set first Y overlay color.
- Set second Y overlay color.
Example 33
Summary: Creates a bar chart to visualize mean height by age and sex, with horizontal layout, stacked bars, and labels.
Code:
Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ) ), Horizontal( 1 ), Stack Bars( 1 ), Label by Value, Show Labels, Bar Chart( 1 ) );
Code Explanation:
- Open data table;
- Create chart object.
- Set X-axis variables.
- Set Y-axis variable.
- Enable horizontal layout.
- Enable stack bars option.
- Label by value.
- Show labels on bars.
- Use bar chart type.
- Display chart.
Example 34
Summary: Creates a stacked bar chart to visualize mean height by age and sex, with horizontal layout and labeled bars.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ) ), Horizontal( 1 ), Stack Bars( 1 ), Label by Value, Show Labels, Bar Chart( 1 ) );
Code Explanation:
- Open data table.
- Create chart object.
- Set X-axis variables.
- Set Y-axis variable.
- Enable horizontal layout.
- Stack bars option.
- Label by value.
- Show labels.
- Enable bar chart.
Example 35
Summary: Creates a line chart to visualize the mean sales and assets for each type, using JMP's Chart platform.
Code:
Open("data_table.jmp");
obj = Chart( X( :Type ), Y( Mean( :Name( "Sales($M)" ) ), Mean( :Name( "Assets($Mil.)" ) ) ), Line Chart( 1 ) );
Code Explanation:
- Open data_table data
- Create chart object.
- Set X-axis to Type.
- Add Sales mean to Y-axis.
- Add Assets mean to Y-axis.
- Enable line chart.
Example 36
Summary: Creates a line chart to visualize mean sales and assets by type, utilizing JMP's Chart platform.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Type ), Y( Mean( :Name( "Sales($M)" ) ), Mean( :Name( "Assets($Mil.)" ) ) ), Line Chart( 1 ) );
Code Explanation:
- Open data table;
- Create chart object.
- Set X-axis to Type.
- Add Mean Sales to Y-axis.
- Add Mean Assets to Y-axis.
- Enable line chart.
Example 37
Summary: Creates a range chart with two series, using Mean(Sales ($M)) and Mean(Profits ($M)) as y-axis values, and Size Co as the x-axis.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :Size Co ), Y( Mean( :Name( "Sales ($M)" ) ), Mean( :Name( "Profits ($M)" ) ) ), Range Chart( 1 ) );
Code Explanation:
- Open data table;
- Create a new chart object.
- Set X-axis to Size Co.
- Add Mean(Sales ($M)) to Y-axis.
- Add Mean(Profits ($M)) to Y-axis.
- Enable range chart.
- Configure range chart for first series.
Example 38
Summary: Creates a stacked bar chart from a data table, customizing colors for each level and applying a bar chart style.
Code:
dt = Open("data_table.jmp");
obj = Chart(
X( :Type, :Size Co ),
Y( Mean( :Name( "Sales ($M)" ) ) ),
Stack Bars( 1 ),
Bar Chart( 1 ),
Level[1] << Colors( 4 ),
Level[2] << Colors( 9 ),
Level[3] << Colors( 3 )
);
Code Explanation:
- Open data table.
- Create chart object.
- Set X axis variables.
- Set Y axis variable.
- Enable stacked bars.
- Apply bar chart style.
- Customize level 1 colors.
- Customize level 2 colors.
- Customize level 3 colors.
Mean using Summarize
Example 1
Summary: Runs data summarization by sex, calculating the mean height for each group.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "invisible" );
Summarize( dt, exg = By( :sex ), exm = Mean( :height ) );
Code Explanation:
- Open data table;
- Summarize data by sex.
- Calculate mean height for each sex.
Example 2
Summary: Runs data summarization by sex and calculates the mean height, utilizing the Summarize platform in JMP.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "private" );
Summarize( dt, exg = By( :sex ), exm = Mean( :height ) );
Code Explanation:
- Open data table;
- Assign dataset to variable.
- Summarize data by sex.
- Calculate mean height.
- Store results in variables.
Example 3
Summary: Runs data summarization by sex, calculating the mean height for each group.
Code:
Open("data_table.jmp");
Summarize( var1a = By( :sex ), var1b = Mean( :height ) );
Code Explanation:
- Open data table;
- Summarize data by sex.
- Calculate mean height for each sex.
Mean using Text Edit Box
Example 1
Summary: Creates a bar chart to visualize mean height by age, utilizing text edit boxes and rectangles for customization.
Code:
cert text edit bx = {Text Edit Box( "Mean(height)", default font id( 9 ), wrapWidth( 277 ), justification( 1 ), vjustification( 1 ), left )
};
cert title = {Title( "age" )};
cert labels = {"Labels", Labels( "12", "13", "14", "15", "16", "17" )};
cert rect = {Rect( 0.855595667870036, 66.6666666666667, 0.945848375451264, 0, 1 ), Rect(
0.693140794223827,
64.3333333333333,
0.783393501805054,
0,
1
), Rect( 0.530685920577617, 64.5714285714286, 0.620938628158845, 0, 1 ), Rect(
0.371841155234657,
64.1666666666667,
0.462093862815885,
0,
1
), Rect( 0.209386281588448, 60.2857142857143, 0.299638989169675, 0, 1 ), Rect( 0.0469314079422383, 58.125, 0.137184115523466, 0, 1 )};
dt = Open("data_table.jmp");
obj = dt << Chart(
X( :age ),
Y( Mean( :height ) ),
Level[1] << Colors( 72 ),
Level[2] << Colors( 72 ),
Level[3] << Colors( 72 ),
Level[4] << Colors( 72 ),
Level[5] << Colors( 72 ),
Level[6] << Colors( 72 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Create text edit box.
- Set title "age".
- Define labels for age groups.
- Define rectangles for bar chart.
- Open data table;
- Create bar chart of mean height by age.
- Set colors for bar levels.
- Generate report from chart.
Example 2
Summary: Creates a bar chart with multiple series, utilizing text edit boxes for input and custom rendering styles.
Code:
cert label = {label( "Mean(BP 8M)" ), label( "Mean(BP 12M)" ), label( "Mean(BP 6M)" ), label( "Mean(BP 8W)" )};
cert text edit bx = {Text Edit Box( "Y", default font id( 9 ), wrapWidth( 277 ), justification( 1 ), vjustification( 1 ), left )};
cert title = {Title( "Dose" )};
cert labels = {"Labels", Labels( "A", "B", "Control", "Placebo" )};
cert rs = {rs( 0, Dot, 4 ), rs( 0, Dot, 3 ), rs( 0, Dot, 8 ), rs( 0, Dot, 9 )};
cert rect = {Rect( 0.898916967509025, 181.274811443348, 0.942238267148014, 0, 1 ), Rect(
0.660649819494585,
177.186763443482,
0.703971119133574,
0,
1
), Rect( 0.422382671480144, 184.238884423777, 0.465703971119134, 0, 1 ), Rect(
0.184115523465704,
176.138183331992,
0.227436823104693,
0,
1
), Rect( 0.855595667870036, 181.006139550061, 0.898916967509025, 0, 1 ), Rect(
0.617328519855596,
180.734825407513,
0.660649819494585,
0,
1
), Rect( 0.379061371841155, 180.202909288621, 0.422382671480144, 0, 1 ), Rect(
0.140794223826715,
179.415573829326,
0.184115523465704,
0,
1
), Rect( 0.812274368231047, 177.682555628762, 0.855595667870036, 0, 1 ), Rect(
0.574007220216607,
180.949644217605,
0.617328519855596,
0,
1
), Rect( 0.335740072202166, 182.75321496061, 0.379061371841155, 0, 1 ), Rect( 0.0974729241877256, 179.9324183333, 0.140794223826715, 0, 1 ),
Rect( 0.768953068592058, 179.353123836291, 0.812274368231047, 0, 1 ), Rect( 0.530685920577617, 180.530731287898, 0.574007220216607, 0, 1 ),
Rect( 0.292418772563177, 176.722603031539, 0.335740072202166, 0, 1 ), Rect(
0.0541516245487365,
180.141228733493,
0.0974729241877256,
0,
1
)};
dt = Open("data_table.jmp");
obj = Chart(
X( :Dose ),
Y( Mean( :BP 8M ), Mean( :BP 12M ), Mean( :BP 6M ), Mean( :BP 8W ) ),
y[1] << overlay color( 4 ),
y[2] << overlay color( 3 ),
y[3] << overlay color( 8 ),
y[4] << overlay color( 9 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Define labels for bar chart.
- Create text edit box for input.
- Set chart title.
- Define labels for categories.
- Define rendering styles for bars.
- Define rectangles for chart elements.
- Open data_table data
- Create bar chart object.
- Assign colors to different series.
- Generate report from chart object.
Example 3
Summary: Creates a bar chart to visualize mean height by sex, utilizing a text edit box for customization and a report object for output.
Code:
cert text edit bx = {Text Edit Box( "Mean(height)", default font id( 9 ), wrapWidth( 277 ), justification( 1 ), vjustification( 1 ), left ),
Text Edit Box( "Mean(height)", default font id( 9 ), wrapWidth( 277 ), justification( 1 ), vjustification( 1 ), left )};
cert label = {label( "F" ), label( "M" ), label( "sex" )};
cert title = {Title( "age" )};
cert labels = {"Labels", "Labels", Labels( "12", "13", "14", "15", "16", "17" )};
dt = Open("data_table.jmp");
obj = Chart(
Grouping( :sex ),
X( :age ),
Y( Mean( :height ) ),
Level[1] << Colors( 72 ),
Level[2] << Colors( 72 ),
Level[3] << Colors( 72 ),
Level[4] << Colors( 72 ),
Level[5] << Colors( 72 ),
Level[6] << Colors( 72 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Define text edit boxes.
- Define labels.
- Define title.
- Define labels.
- Open data table;
- Create chart object.
- Group by sex.
- Set X-axis to age.
- Set Y-axis to mean height.
- Generate bar chart.
Example 4
Summary: Creates a bar chart to visualize sales and profits by size category within type, utilizing a custom layout and color scheme.
Code:
cert label = {label( "big" ), label( "medium" ), label( "small" )};
cert text edit bx = {Text Edit Box( "Mean(Sales ($M))",
default font id( 9 ),
wrapWidth( 277 ),
justification( 1 ),
vjustification( 1 ),
left
), Text Edit Box( "Mean(Profits ($M))", default font id( 9 ), wrapWidth( 277 ), justification( 1 ), vjustification( 1 ), left )};
cert labels = {"Labels", "Labels", Labels( "Computer", "Pharmaceutical" ), Labels( "big", "medium", "small" )};
cert title = {Title( "Size Co within Type" )};
cert rect = {Rect( 0.859205776173285, 1083.75, 0.945848375451264, 0, 1 ), Rect( 0.703971119133574, 4261.06, 0.790613718411552, 0, 1 ),
Rect( 0.545126353790614, 7474.04, 0.631768953068592, 0, 1 ), Rect( 0.357400722021661, 1758.05714285714, 0.444043321299639, 0, 1 ),
Rect( 0.202166064981949, 3018.85, 0.288808664259928, 0, 1 ), Rect( 0.0469314079422383, 20597.475, 0.133574007220217, 0, 1 ),
Rect( 0.859205776173285, 156.95, 0.945848375451264, 0, 1 ), Rect( 0.703971119133574, 698.98, 0.790613718411552, 0, 1 ),
Rect( 0.545126353790614, 894.42, 0.631768953068592, 0, 1 ), Rect( 0.357400722021661, 44.9357142857143, 0.444043321299639, 0, 1 ),
Rect( 0.202166064981949, 0, 0.288808664259928, -85.75, 1 ), Rect( 0.0469314079422383, 1089.925, 0.133574007220217, 0, 1 )};
dt = Open("data_table.jmp");
obj = Chart(
X( :Type, :Size Co ),
Y( Mean( :Name( "Sales ($M)" ) ), Mean( :Name( "Profits ($M)" ) ) ),
Overlay( 0 ),
Level[1] << Colors( 4 ),
Level[2] << Colors( 6 ),
Level[3] << Colors( 8 ),
Bar Chart( 1 )
);
rpt = obj << report;
Code Explanation:
- Define
cert labelarray. - Define
cert text edit bxarray. - Define
cert labelsarray. - Define
cert titleobject. - Define
cert rectarray. - Open data table;
- Create chart object with X variables.
- Add Y variables to chart.
- Disable overlay.
- Set colors for levels.
- Generate bar chart.
- Retrieve chart report.
Example 5
Summary: Creates a stacked bar chart from a data table, with customized colors for each level and a text edit box for labeling.
Code:
cert text edit bx = {Text Edit Box( "Mean(Sales ($M))", default font id( 9 ), wrapWidth( 277 ), justification( 1 ), left )};
dt = Open("data_table.jmp");
obj = Chart(
X( :Type, :Size Co ),
Y( Mean( :Name( "Sales ($M)" ) ) ),
Stack Bars( 1 ),
Bar Chart( 1 ),
Level[1] << Colors( 4 ),
Level[2] << Colors( 9 ),
Level[3] << Colors( 3 )
);
Code Explanation:
- Open data table.
- Create text edit box for label.
- Initialize chart object.
- Set X axis variables.
- Set Y axis variable as mean sales.
- Enable stacked bars.
- Set chart type to bar chart.
- Assign color to first level.
- Assign color to second level.
- Assign color to third level.