This post will show you how to set gaps between subgroups, order subgroups in a desired sequence and reconstruct a legend using categorical values from one or more group(s).
If you would like to work through these steps with me, download Grouped Column with Gaps.zip file, extract the contents and open the OPJ file.
Below is what you should see:
In this worksheet, the grouping columns are column Exercise and Dose (Long Name), and Total Alcohol (Long Name) columns are data and its associated error bars.
In the following sections, we will show you how to:
- Create a grouped columns plot
- Set gaps between adjacent subgroups
- Plot the subgroups in a certain order
- Reconstruct the legend using categorical values from a certain group
Create a Grouped Columns Plot
First, let’s quickly make a grouped column plot by highlighting last two columns and go to menu Plot: Column/Bar/Pie: Grouped Columns – Indexed Data … to open dialog. Check Auto Preview checkbox on the bottom to turn on preview on the right panel. Then click the right sided triangle button in Group Column(s) box to select A(X): Exercise and click again to add B(Y): Dose as grouping columns.
Click OK button to close the dialog and you will see a grouped column plot is created as shown below:
Set Gaps Between Adjacent Subgroups
It generally needs two steps:
- Enable the option for setting gaps between subgroups through Axis dialog
- Set the value of the gap through Plot Details-Plot Properties dialog
1. Enable the Option for Setting Gaps
Double click on tick label Light to open X Axis dialog. On the left panel of the dialog, Bottom 1 icon is highlighted which means the bottom-most tick label row, High, Light and Moderate is Bottom1. Therefore tick label row 100, 200 and 300 is Bottom 2.
Tick Labels tab is activated with three 2nd level tabs, Display, Format and Table. Display tab is active by default.
Select Table tab on the same row with Display tab, Under Table Layout node, there is blue hint The table layout of Bottom2 share(s) the settings in Bottom1. Check Gap Between Subgroups/Subsets check box at the bottom to enable customizing gaps between subgroups. Let’s also set Fill Color to be Light Gray and click Apply button. Changes are applied to both tick label rows.
We can have different styles for Bottom 1 and Bottom 2 tick label row. select Bottom 2 on the left panel. Uncheck Auto checkbox under Table Layout node so Bottom 2 will not share Bottom 1‘s settings. Choose None as Fill Color and uncheck Inside Border, Outside Border checkboxes. click OK button. Fill color on 100, 200, 300 tick label rows are removed. Also there is no borders among them.
2. Set the Size of Gaps
As indicated by the blue hint below Gap Between Subgroups/Subsets checkbox, the checkbox only enabled the feature. Whether it has effect or not is decided by Subgroup Size and Gap settings in Plot Details dialog.
Double click on column plot to open Plot Details – Plot Properties dialog and click Spacing tab on the right panel. Note that Spacing tab is only available when the highlighted node on the left panel is a data plot. Input 20 in Gap Between Subsets (%) edit box.
Click Apply button on the bottom, we should see the following graph:
Plot the Subgroups in a Certain Sequence
As we can see from the figure above, current plotting order of the subgroups is High, Light, Moderate. Now we want to re-order it so that the subgroup order is Light, Moderate, High.
To do so, go back to the workbook. Output Data worksheet is created for this graph. Select Sheet1 worksheet. In order to set plotting order, we need to set the column as categorical first. To do so, right click column A header and choose Set as Categorical. We will see a Categories label row will be automatically added. Unsorted means using the appearance order of values in Column A. To customize the order, double click on Unsorted to open Categories dialog.
Now uncheck <auto> Generate from data dynamically checkbox to enable manually change the categorical order. Then click to select a category item in Category column and use the buttons in Category Button Group to order the list as shown below:
Click OK button to close dialog and the subgroup plotting order is automatically updated in the graph.
Reconstruct the Legend Using Categorical Values
When you make a grouped columns plot, the label of data column will be assigned by default as the legend entry. In Origin you can reconstruct the legend using categorical values from one or more grouping columns.
Suppose now we want to use categories 100, 200, 300 in column Dose (Long Name) as the legend entries. To do so, first double click on any column plot to bring up Plot Details-Plot Properties dialog. One the right panel, make sure Pattern tab is selected. You can see that Increment is the default mode used in option Color under Fill control box, now click it and select Indexing then navigate to further choose Col(B): “Dose” as the column for color indexing.
When a column is used as color indexing, it can be used to create a categorical legend. To reconstruct the legend, simply use short key Ctrl + L or click the Reconstruct Legend toolbar button or go to menu Graph: Legend: Categorical Values… and click OK in appeared dialog. Please delete the 1st row of the legend since it shows the whole plot legend. Please also modify the 2nd row of legend to be Dose.
Now we can hide the redundant axis labels from Dose (Long Name) column by double click on any tick label on X axis open up X Axis dialog. Choose Bottom 2 node and uncheck Show checkbox in Tick Labels tab. You can also right click Bottom 2 node on left panel and uncheck Show context menu.
After that, you can simply drag and adjust the positions of the labels from Exercise (Long Name) column properly to obtain the following figure: