In descriptive statistics, a box plot is an effective graphical representation of five-number summary, while histogram is a type of bar chart to visualize the distribution of a dataset. Each of them has its place and its limitations. To better depict the data trends and dispersion, users may want to plot both of them at the same time. This blog will show you how to create the following box plot with its corresponding histogram on the same graph.
The project is available to download from here. Sample data is the historical rate of CNY per 1 USD in 2015.
Let’s make a box plot first. Go to Book1 and highlight column B(Y), then plot from menu Plot: Statistics : Box Chart. Double click on the plot to open Plot Details dialog. Go to Box tab and select Box[Right]+Data[Left] from Type drag-down menu. Click Apply button.
After Box[Right]+Data[Left] type is selected, there will be an another tab Data appeared specifically for customizing the data. Go to Data tab, select Bin Bars from Type drag-down menu. Note: In Origin 2016 and before, it’s called Bars. and set Bins Alignment as Left. Click OK to close the dialog.
Now the box plot is aligned to the right of the histogram. We can easily choose Graph : Exchange X->Y Axes menu or just press the corresponding toolbar button on the right side of workspace to rotate the display so that box is on top of the histogram.
This is pretty much the graph that we want. You can do further customization if you want to get similar graph on top of the blog.
Double click plot to open Plot Details again. On Pattern tab, change Border Color from red to blue and you can also customize the Fill Color, Pattern and any other setting if you would like to.
Go to Box tab, first change Box Width to 60% and check the Box Labels and Whisker Labels checkboxes to show labels on the graph. There is no any outlier shown from the box plot, meanwhile we are interested in the lowest and highest rate, so we set Whisker Range as Min-Max. You can also go to Spacing tab to adjust the Gap Between Boxes which will change the width of box width and space between histogram and box. E.g. set it to 10.
As for Data tab, set Data Width to 100%, Select Kernel Smooth in Type dropdown list of Distribution Curve to display the kernel density of the dataset.
In Percentile tab, set Edge Color as red to make the mean of dataset distinct. Go to Lines tab to customize distribution curve.
To add several reference lines onto the graph, In Origin 2017. in Double click on X axis to open the X Axis dialog, go to the Reference Lines tab, type the specific statistical values (the numeric labels shown on the graph) in Reference Lines at Value edit box and click within the table to update the values into the table. Click OK button.
Note: In Origin 2016 and before, to add reference lines, you must choose Graph: Add Straight Line… menu to add them one by one.
The Last step is to add layer title. Right click the graph and select Add/Modify Layer Title, type in “Chinese Yuan to U.S. Dollar in 2015”. Then you should get some graph similar to Graph1 on the top of the blog.