Reputation: 11
I have a (x,y) coordinate which will be plotted in a scatter plot. I need a circle of radius R to be drawn around the point plotted.
Thanks and Regards, Prabhu.C
Upvotes: 1
Views: 3119
Reputation: 1952
A 'bare bones' example which may get you started. You will need to play with scaling, units and positioning etc. to suit your context.
This will draw a circle with no fill and a red circumference, with a commented-out line to give it a solid fill (change .Visible to msoTrue).
Sub drawCircle()
Dim ws As Worksheet
Dim cLeft As Long, cTop As Long
Dim cX As Long, cY As Long, cDia As Long
Dim c1 As Shape
Set ws = Sheets("Sheet1")
cX = Range("A2")
cY = Range("B2")
cDia = Range("C2").Value * 2
cLeft = cX - (cDia / 2)
cTop = cY - (cDia / 2)
With ws
Set c1 = .Shapes.AddShape(msoShapeOval, cLeft, cTop, cDia, cDia)
With c1
.Fill.Visible = msoFalse
.Line.Weight = 2
.Line.ForeColor.RGB = RGB(255, 0, 0)
'.Fill.ForeColor.RGB = RGB(255, 0, 0) 'eg Red fill
End With
End With
End Sub
Upvotes: 1