Excel 2010 - Plot lines between multiple ordered pairs

FLSteve

New Member
Joined
Dec 4, 2011
Messages
9
I've got multiple ordered pairs and would like to plot them on a scatter plot and draw a pairing line between each ordered pair.

Series 1; Series 2
X1, Y1; A1, B1
X2, Y2; A2, B2
X3, Y3; A3, B3
X4, Y4; A4, B4


Basically all 8 points would be plotted and I'd like a line between X1, Y1 and A1, B1 and the other 3 pairs.
Any ideas? I know how to plot all the points on a scatterplot. I don't know how to draw the 'pairing lines'
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this code:

Code:
Sub createChart()
    'create a chart
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlXYScatterSmooth
    
    'we have to create a series for each pair of points
    Dim cell As Range
    'change Range("A1:A3") to your range
    For Each cell In Range("A1:A3")
        With ActiveChart.SeriesCollection.NewSeries
            .Name = cell.Row
            
            'xRange are X and A values
            xRange = "A" & cell.Row & ",C" & cell.Row
            'yRange are Y and B values
            yRange = "B" & cell.Row & ",D" & cell.Row
            
            .XValues = ActiveSheet.Range(xRange)
            .Values = ActiveSheet.Range(yRange)
        End With
    Next cell


End Sub
 
Upvote 0
If you don't want to use code you can also do it manually. Create a scatter with lines chart and then for each pair of points add a seperate series (in select data menu of the chart). For X values pick X and A cells and for Y values pick Y and C cells.
For example for pair number 2, X values would be cell X2 and A2 and Y values would be Y2 and B2.
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top