UNC-Wilmington Department of Economics and Finance ECN 377 Dr. Chris Dumas Excel—Scatter Plots (X-Y Graphs) Recall that Scatter Plots are graphs that show the corresponding values for two or more variables. For example, a graph that shows the (X,Y) ordered pairs from a data set with variables X and Y is a scatter plot. This handout will explain how to make scatter plots in Microsoft Excel 2013. The ProcCorrData.xls Dataset This handout will use the ProcCorrData.xls dataset as an example. If you haven't done so already, go to the Handouts page of the ECN377 website and download the ProcCorrData.xls dataset to the ECN377 folder on the C: drive of your computer. The ProcCorrData.xls dataset contains data on 9 variables for a random sample of 45 North Carolina counties (out of the total population of 100 North Carolina counties), as described in the table below: Variable Name CntyName PopCens LandArea PM10Area HousingUnits EmpManf2000 VehRegs PavedMiles MeanFamInc Variable Definition Name of county in North Carolina Population in county in year 2000 Land area (square miles) in county in year 2000 Air pollution index (estimated emissions in tons of air pollution particles less than 10 micrometers in size) for county in year 2000 Total of houses, apartments, mobile homes, etc., in county in year 2000 Manufacturing employment in county in year 2000 Number of cars and trucks registered (owned and located) in county in year 2000 Number of miles of paved roads in county in year 2000 Average (mean) household income in county in year 2000 Open the ProcCorrData.xls Dataset in Excel The first four rows should look like this: Variables Arranged by Columns This dataset has the variables arranged by columns; that is, the values for a particular variable are placed in a column (as opposed to a row). This is probably the most common way to arrange data in a dataset. This handout will explain how to make scatter plots for datasets that have the variables arranged by column, as in dataset ProcCorrData.xls. 1 UNC-Wilmington Department of Economics and Finance ECN 377 Dr. Chris Dumas Creating a Scatter Plot for Two Variables With the ProcCorrData.xls dataset open in Excel: Suppose that you want to make a scatter plot with variable LandArea graphed on the X axis and variable PavedMiles graphed on the Y axis. In Excel, you need to place the columns of the variables you want to graph beside one another on the spreadsheet, with the variable for the X axis on the left. So, for example, select column C (do this by clicking on the "C" in the margin of the worksheet at the top of column C) for the LandArea variable, copy it, and then paste it into column K (do this by clicking on the "K" in the margin of the worksheet at the top of column K, and then click paste). Similarly, select column H (for the PavedMiles variable), copy it, and paste it into column L. With the columns of the two variables now placed adjacent to one another, select the cells that contain the data that you want to graph (in this case, cell K1 to cell L46), select the "Insert" tab at the top of the Excel window, then find the "charts" area of the menu bar and click on the scatter plot button . The "Scatter" sub-menu should pop up. Click on the picture of a graph that has simple data points on it. A pop-up window should appear with a scatter plot labeled "PavedMiles." If you want, you can "click and hold" the edge of the graph and move it to a place on the spreadsheet that is more convenient and that doesn't obscure the data, such as to the right of column L. Because your worksheet has the names of the variables in the first row, and you selected the variable names when you selected the data, Excel automatically uses the name of the Y variable as the title of the scatter plot. You can change this, if you want, as described below. Also, if your dataset does not have the names of the variables in the first row, or if you did not select the variable names when you selected the data for plotting, then at this point your graph may not have a title. Changing the Size of the Plot Click on the chart to select it, then click, hold and drag one of the corners of the chart to change its size. Adding/Changing the Plot Title and Axes Titles Single-Click on the chart to select it. Under "Chart Tools" at the top of the Excel window, choose the "Design Tab." On the Design Tab, select "Add Chart Element," and then select "Chart Title," and then "Above Chart." Type "Paved Miles vs. Land Area" then hit the <enter> key to change the title of the chart. Next, return to "Add Chart Element" and select "Axes Titles," and then "Primary Horizontal." Type "Land Area (square miles)" <enter> to change the title of the X axis. Next, return to "Add Chart Element" and select "Axes Titles," and then "Primary Vertical." Type "Paved Miles" <enter> to change the title of the Y axis. It should look like this: 2 UNC-Wilmington Department of Economics and Finance ECN 377 Dr. Chris Dumas Printing the Plot Click on the chart to select it, then go to File at the top of the Excel window, then select Print. (That was easy.) Saving the Plot The chart will be saved as part of the Excel file when you save the Excel file. So, simply save the Excel file in order to save the chart. Copying the Chart to MS Word, Centering and Re-sizing the Chart in MS Word You will often want to copy a chart that you have made in Excel from Excel to MS Word, where it can be included as part of a report that you write in MS Word. In Excel, click on the chart to select it, then go to the Home tab on the Excel menu and click the Copy icon , then go to your MS Word document and select "Paste." In MS Word, you can click on the chart to select it, and then you can go to the Home tab in Word and click the "Center" button to center the chart on the page. In MS Word, you can click on the chart to select it, and then click and drag a corner of the chart to re-size it. Overlay Plots -- Graphing More than One Y Variable on the Same Plot When you graph more than one Y variable on an X-Y scatter plot, notice that both Y variables will be graphed against the same X variable. In Excel, line up your columns of data so that the X variable comes first (on the left), and then the Y variables come next (on the right). If you have more than one Y variable, put the columns of data for the Y variables side-by-side, to the right of the column of data for the X variable. For example, if we wanted to plot PavedMiles and VehRegs as two Y variables against LandArea (the X variable), we would need to arrange the columns like this: Select the cells that contain the data that you want to graph (in this case, cell K1 to cell M46), select the "Insert" tab at the top of the Excel window, then find the "charts" area of the menu bar and click on the scatter plot button . The "Scatter" sub-menu should pop up. Click on the picture of a graph that has simple data points on it. A pop-up window should appear with a scatter plot labeled "Chart Title." Click and hold" the edge of the graph and move it to a place on the spreadsheet that is more convenient and that doesn't obscure the data, such as under the "Paved Miles vs. Land Area" plot that we made earlier. Notice that all of the data points for Paved Miles appear to lie on the X-axis. That's because the value of Paved Miles is typically much smaller than the value for VehRegs, and Excel is using the values of VehRegs to label the Y-axis. When the values of one Y variable are very much larger or smaller than the values of another Y variable, then you may want to graph the two Y variables using separate Y axes (this 3 UNC-Wilmington ECN 377 Department of Economics and Finance Dr. Chris Dumas only works if you are graphing two Y variables; for more than two Y variables, only graph them on the same plot if their values are not too different from one another). In order to get a better view of the pattern in the Paved Miles data points, we need to tell Excel to graph the Paved Miles data points using a separate Y-axis. To get a separate Y-axis for Paved Miles, first click on the chart to select it. Under "Chart Tools" at the top of the Excel window, select the "Design" tab, select "Add Chart Element," select "Axes," then select "More Axes Options..." The "Format Axis" window will appear at the right of the Excel window. In the "Format Axis" window, select "Axis Options" at the very top of the window (the words "Axis Options" appears in two places in the window), then select "Series PavedMiles." The "Format Data Series" window will appear at the right of the Excel window. Select "Secondary Axis," and a second Y-axis will appear on your plot, to the right of the plot. Now your plot has two Yaxes—the Y-axis on the left is the one for VehRegs, and the Y-axis on the right is the one for PavedMiles. Now you can see more clearly the pattern (if any) in the PavedMiles data points. At this point the overlay plot should look something like this: If you want, you can change the title of the chart, and the names of the axes, as described earlier in the handout. 4