Data Visualization: Bar Charts

Our first semester, we spent our time discussing and reviewing what Data Visualization is all about, the graphic design aspects of Data Viz, the anatomy of charts and tables.  This semester I’d like to start creating examples of data visualizations.  Since a question that comes up every now and again is:  What is the best way to visualize my results? I’d like to work through common examples and possibly look at how to do these in the different packages we have access to.  I would also like to compile a list of questions that could be answered by our visualization du jour.  My end goal is to have you, the community, provide different examples, walk us through how you created, why you created it, and discuss different options you may not have considered.

Given all of the above, let’s start with a simple Bar chart.  I’ll start with using Excel and see how far we can get using SPSS, SAS, R, and Sigmaplot.

For today’s adventure let us use a small dataset that contains 4 observations of height for 3 treatment groups of plants:

Treatment Group                 Height

GroupQ                                          19
GroupQ                                            4
GroupQ                                          11
GroupQ                                            6

GroupT                                           24
GroupT                                           29
GroupT                                           21
GroupT                                           22

GroupK                                           11
GroupK                                           18
GroupK                                           15
GroupK                                           13

Preparing the Data

It would be wonderful if our programs knew that we want to plot the mean of each group with its standard error, but unfortunately, some programs cannot do this.  Excel is one of these.  We need to provide the means and standard errors for Excel in order for it to create the appropriate bar chart.

Treatment Group    Mean        StdErr
GroupK           14.25           1.49
GroupQ           10.00           3.34
GroupT            24.00           1.78

You will need to enter these values into an Excel spreadsheet or download the file I have already prepared prepared here.

Creating a Bar Chart with Error Bars in Excel

Steps to create bar chart:

  1. Highlight the columns with the treatment group names and means – use your Ctrl key to select cells that are not next to each other
  2. Select the Insert Tab in Excel
  3. Select the 2D bar chart

2D barchart

You should now see a very basic chart with 3 bars, each representing the mean of their respective groups.

Steps to add error bars:

  1. Select the Chart
  2. Click or ensure that the Design tab under the Chart Tools is selected
  3. Click Add Chart Element (top left hand corner of the menu bar)
  4. Select Error bars – More Error Bar options – Format Error Bars dialogue box should show up on your screen – usually at the right hand side of your screen.
  5. Select Custom under the Error Amount section of the Vertical Error bar menu
  6. Select Specify Value.
  7. click on the Positive Error Value data entry button, select the 3 standard error cells in the Excel spreadsheet.
  8. Do the same for the Negative Error Values
  9. Click OK

You should now see Error bars on your 3 bars.  They should also be different sizes, reflecting the different variances for the 3 treatment groups.

This bar chart as it stands is NOT publishable quality, what should you do now?

 

Excel is a very straightforward way of creating bar charts and a method that many of us are comfortable with.  If you choose to use Excel to create your bar charts, learning how to move between your Statistical package and Excel can save you a lot of time!

Creating a Bar Chart with Error Bars in SPSS

SPSS is a statistical software package commonly used in the social sciences.  It has a great feature called Chart Builder, which we’ll review here.  SPSS can be obtained through CCS and is free for the University of Guelph community.

Importing the Excel file into SPSS

Bringing an Excel file into SPSS is extremely straightforward.

File -> Open -> navigate to the directory/folder where you saved the Excel file -> change the File type from SASS (.sav) to Excel.  Select your file, double check that the SPSS import wizard knows which worksheet you want to import, and click OK.  Tadah!  Excel file now in SPSS.

Steps to create a bar chart in SPSS:

  1. Select graphs from the menu bar
  2. Select Chart builder
  3. In the Gallery tab at the bottom of the dialogue box, select the type of graph you want to create.  In this case, a Bar graph.  Double-click the simple bar chart
  4. A sample bar chart appears in the top part of the window.  You should also see your variables in the Variables box to the left of the graph window.
  5. Drag and drop TRMT to the x-axis
  6. Drag and drop Height to the y-axis
  7. In the Element Properties dialogue box – if it is not open, click on the Element Properties button
  8. We want to ensure that SPSS will calculate the means of each treatment group.  You should see under statistic: Mean is selected for the variable Height.
  9. Click Display Error bars and select Standard Error.
  10. Click Apply and then Click OK to create the bar chart.

As with Excel, you should now see 3 bars matching the 3 treatment groups and their appropriate error bars.  They should also be different sizes, reflecting the different variances for the 3 treatment groups.

This bar chart as it stands is NOT publishable quality, what should you do now?

Creating a Bar Chart with Error Bars in SAS

YES!  You can create publication-quality graphs using SAS!  However, it is or rather it can be challenging.  To review the types of graphs you can create in SAS, please review this link on the SAS Support pages.

Creating a Bar Chart with Error Bars in Sigmaplot

 

Which program to choose for your graphing requirements?

The answer to this is going to depend on your comfort with the program and time that you have.  Most programs, Excel, SPSS, SAS, and Sigmaplot can all create publication-quality graphs.   You need to ensure that you have all the bits and pieces or that you have a complete anatomy of your chart.

The next Data Visualization session will look at creating Regression Lines in all 4 packages.  Please stay tuned for a change in the time of the next session on Wednesday, February 7, 2018

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: