6.10.9 Notched Boxes with Variable Width Control
Origin's box plot is highly customizable. This tutorial shows how to create a notched box plot and control the box width by another dataset.
Minimum Origin Version Required: 2015 SR0
What you will learn
- Customize box plot settings
- Use a dataset to control the box width
- Customize the axis dialog for box plots
- Add a fill area plot to a box plot as background
Steps to Control Box Width by Variable
This tutorial is associated with <Origin EXE Folder>\Samples\Tutorial Data.opj.
- Open the Tutorial Data.opj and browse to the Box Variable Width folder.
- Activate workbook Book1CAA, go to Sheet1. Highlight columns B to I (do not select column C) and then select Plot: Statistics: Box Chart. Next, select and delete the legend object from the graph.
- Double-click on one of the boxes to open the Plot Details dialog and go to the Box tab. Set Style to Notched Box. Select the Box Width by Parameter box and then set Box Width (%) to Units and enter 1.2 for Scaling Factor. Select the Outliers box. Outliers in Line is automatically checked.
- Click OK button. The graph will look as below.
More Box Style Customization Steps
The following steps can further customize the box plot.
- To use the same color for each box, double-click on any box to open the Plot Details dialog box. Go to the Group tab and change the Increment of Border Color to None:
- Go to the Pattern tab. Set Border Color as Orange. Set Width as 1.5.
- To fill the boxes with color, click Fill Color drop down list and choose Define Custom Color. Add a custom color as below.
- Note that checking Outliers checkbox in Box tab added a Symbol tab. Use controls on this tab to customize the outlier symbol as shown below:
- To hide the 99% and 1% symbols, go to the Percentile tab and clear the symbol for both 99% and 1%. Select the 2nd symbol in the first row for Mean:
- Click OK button to accept all the changes.
More Axis Customization Steps
- To show solid grid lines between each boxes, double click on the X axis to open the Axis dialog box. Go to the Scale tab with Horizontal icon selected and set the Count of Minor Ticks to 1:
- Select the Grids tab and select the Vertical icon. Check Show under Minor Grid Lines branch and set the Style as Solid.
- Go to the Line and Ticks tab and set the tick styles for X axis (Bottom):
- Hold Ctrl key and multiple select the Top and Right icons. Check the Show Line and Ticks box to also display line and ticks of top X and right Y axis:
- Go to the Scale tab again and select Vertical icon. Set the following:
- Go to the Tick Labels tab, make sure Left icon is selected and enter a prefix of $.
- Go to the Title tab, make sure Left icon is selected and change the text of Y axis title to Gasoline Prices.
- Click OK to close the Axis dialog.
- To add a title and footnote in the graph, right click in white area of the graph and select Add/Modify Layer Title context menu. Type US Weekly Retail Gasoline Prices. Select the title and use the Format toolbar to set font size as 26. Right click below the X axis tick labels and choose Add Text... context menu. In in-place edit mode, click I button on Format toolbar and then type Box width indicates number of vehicles in each area as a footnote. It will show in italics.
Steps to Add National Average Line and Min&Max Range
Note: If you right-click on status bar and select Min and Max, then highlight column C (with long name national) of Book1CAA Sheet1, you can see the Average=3.54, Min=3.198 and Max=3.877 of this column on status bar of Origin. Min and Max values have been put to Sheet2 so we can plot them as filled area in box chart.
- To add a National Average line in graph, select Graph:Add Straight Line to add a horizontal line to represent the national average value = 3.54 and click OK button.
- Right click 3.54 label and choose Properties... context menu. Enter the text and set style as below.
- To add national average range as a filled area in the graph, double click Layer1 icon on top-left corner of the graph to open Layer Contents dialog. Select B(Y) and C(Y) from Sheet2. Choose Plot Type to be Line. And click -> button to add two line plots into the box chart.
- Double click the newly added line to open the Plot Details dialog. Go to the Line tab and set the line transparency to be 100 so the lines will not display in graph.
- The Pattern tab is added when fill area is enabled. Set the Fill color and Transparency as below and then click OK button.
- We can use Graph theme to change all text font in the graph to Verdana. Select Tools:Theme Organizer menu.
- There is no Graph theme called Verdana Font. But there is a Times New Roman Font theme. You can create a Verdana Font theme based on it.
- Right click Times New Roman Font theme and choose Duplicate.
- Double click the Duplicated theme and rename it as Verdana Font.
- Right click Verdana Font theme and choose Edit...
- In Theme Editing dialog that opens, change the Face to Verdana and click Save button. Also, you can update the Description on this dialog. Then click on the Save button to save the setting and close the dialog.
- With Verdana Font still selected in Theme Organizer, click the Apply Now button to apply the font to all text objects in the graph.
- Manually reposition the text objects, as needed, so that your graph looks like the one in Summary.