# Plot a scatter, a line and a quadatic function in the same graph in Excel

I have two groups of data. One group has three points: (0.5, 2), (1.5, 3) and (4, 5). The other group has two points: (0, 1) and (3, 4). I want to plot the first group as a scatter plot, and the second as a straight line segment, and a quadratic function $y=x^2$ over $x \in [0,5]$ in the same plot. I wonder how to do that in Excel?

I know how to plot the first group as a scatter plot. First create a column with data: 0.5, 1.5 and 4, and another column with data: 2, 3 and 5; then select the two columns, and click "Insert -> Scatter" and choose a type of scatter plot.

But I don't how to plot the other two, i.e. a line segment and a quadratic function.

I also don't know how to plot them in the same graph as the scatter plot. If I plot the second group of data, it will be plotted in another graph. How can I plot it in the same plot as the first group of data?

Excel 2007.

-

## migrated from stackoverflow.comSep 28 '11 at 5:34

This question came from our site for professional and enthusiast programmers.

For the line segment, you just choose to plot as a scatter plot, but use a line to connect the points.

For the quadratic, you will need to compute a number of points on your curve and then plot them also as a scatter plot, and again, use a line to connect the points from your minimum X value up to your maximum X value.

Update (for Excel 2007 ... probably similar for other versions, but this is what I have in front of me):

1. Right click on an empty place in your chart and select "Select Data"
2. Select "Add" from the Series list
3. Optionally, name the series in the Series name textbox ... it will be given a default name if you don't provide one.
4. Click on the Series X data textbox, and select the X values for your scatter plot
5. Click on the Series Y data textbox, and select the Y values corresponding to the X values you just selected
6. Press "OK"
-
Thanks! If I plot the second group of data, it will be plotted in another graph. How can I plot it in the same plot as the first group of data? –  Tim Sep 27 '11 at 16:55
Using the line segment is smart for the linear part. Didn't think of that! +1 –  JW. Sep 27 '11 at 16:56
@Tim: You just add another data series to your plot, and choose the data from the spreadsheet. –  andand Sep 27 '11 at 16:58
Thanks! How shall I "add another data series to my plot and choose the Y values"? –  Tim Sep 27 '11 at 17:01
@Tim: See edit above –  andand Sep 27 '11 at 18:01

I'd have four columns: X, your scatter, your linear, and your quadratic. Have X go from 0 to 4 in steps of 0.01 (use fill ... series). Fill the three scatter points in the appropriate place. Then fill the other two columns with your function values for the line segment and the parabola. Adjust the size of the points in the last two so they're a little thinner and look like lines rather than points.

-