Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to labe an XY scatter plot 1

Status
Not open for further replies.

vtmike

Mechanical
Mar 12, 2008
139
As far as I know there is no way to label each point in a XY scatter plot. Has anyone come across a macro that can do this? or any other means?

Thanks,
Mike
 
Replies continue below

Recommended for you

what kind of label are we talking?
x value
y value?
x, y pair?
other text?

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
You can turn on the default data labels in the chart:

Format Data Series | Data Labels

TTFN

FAQ731-376
 
I mean a data label for each point on the XY scatter plot extracted from a third column containing the labels.
 
This label would be a text
 
Never mind.......This macro I found works for me,

Sub LabelPoints()
'
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select

Dim myXValues As Range
Dim myYValues As Range
Dim myNameValues As Range

Set myXValues = Application.InputBox(prompt:="Range of X Values?", Type:=8)
Set myYValues = Application.InputBox(prompt:="Range of Y Values?", Type:=8)
Set myNameValues = Application.InputBox(prompt:="Range of Labels?", Type:=8)

For i = 1 To 20
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i).XValues = myXValues(i)
ActiveChart.SeriesCollection(i).Values = myYValues(i)
ActiveChart.SeriesCollection(i).Name = myNameValues(i)

ActiveChart.SeriesCollection(i).Select
With Selection.Border
.Weight = xlHairline
.LineStyle = xlNone
End With
With Selection
.MarkerBackgroundColorIndex = 25
.MarkerForegroundColorIndex = 25
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
Next

End Sub


Thanks,
Mike
 
This is a little bit late (after you have found a way to do it). But the following thread provided several approaches:
thread770-221006

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor