1

Question: How would one recreate a plot similar to the one below?

  • Notice that the points are labelled.
  • To keep things easy, suppose our points are $(1,1)$ with label "point1" and $(1, 2)$ with label "point2". (This means the plot can't modeled as a function, since $1$ appears in the domain twice).
rcollyer
  • 33,976
  • 7
  • 92
  • 191
George
  • 3,145
  • 7
  • 21

1 Answers1

5

There are two methods: Labeled or Callout, as follows:

ListPlot[{Labeled[{94, 1}, "lisbon"], Labeled[{89, 87}, "antwerp"], 
  Labeled[{7, 33}, "boston"], Labeled[{30, 26}, "edinburgh"], 
  Labeled[{32, 60}, "lima"]}]

enter image description here

ListPlot[{Callout[{94, 1}, "lisbon"], Callout[{89, 87}, "antwerp"], 
  Callout[{7, 33}, "boston"], Callout[{30, 26}, "edinburgh"], 
  Callout[{32, 60}, "lima"]}]

enter image description here

As you can see, the primary difference is the addition of callout lines. It should be noted, an avoidance algorithm is used and can result in some of the labels not being displayed as they're converted to Tooltips, e.g.

count = 100;
points = RandomInteger[{0, 100}, {count, 2}];
labels = "label " <> ToString[#] & /@ Range[count];
ListPlot[MapThread[Labeled, {points, labels}]] 
ListPlot[MapThread[Callout, {points, labels}]] 

enter image description here

rcollyer
  • 33,976
  • 7
  • 92
  • 191