6

Let say I want to draw a point and label it. The command I use to draw points is

Graphics[{Point[{0,0}], Point[{1,1}]}]

This draws the points $(0,0)$ and $(1,1)$. How can I label them in the resulting graphics as $(0,0)$ and $(1,1)$?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257

1 Answers1

7

Here's a somewhat ridiculous way to achieve that:

ListPlot[
 {Labeled[{0, 0}, "The first point"], Labeled[{1, 1}, "The second one", Left]},
 Axes -> False
]

Mathematica graphics

MarcoB
  • 67,153
  • 18
  • 91
  • 189
  • 3
    this has the added advantage of using the built-in algorithms for label placement. +1 – rcollyer May 21 '16 at 00:51
  • @rcollyer that's what I was getting at with my link to (45496) above. – Mr.Wizard May 21 '16 at 17:45
  • 1
    @Mr.Wizard expecting me to follow every link? Sheesh, you would think I spent all my time surfing the net. :) – rcollyer May 21 '16 at 21:05
  • @rcollyer lol - no :-) – Mr.Wizard May 21 '16 at 21:09
  • The code didn't work in Mma10.0.2 – Harry Apr 16 '17 at 13:19
  • @Harry strange. I believe I was using v.10 when I wrote this answer, so it should work. What exactly didn't work when you tried? Did you get an error message? What was the output? – MarcoB Apr 16 '17 at 16:07
  • @MarcoB When I try the code above in y Mma10.0.2 on my WIN7, It throw out :"Thread::tdlen: Objects of unequal length in {1, 2} -> {"The first point"} cannot be combined" and " MapThread::mptc: "Incompatible dimensions of objects at positions {2, 2} and {2, 3} of MapThread[Text[#1, Offset[-{2, 1} #3, #2], #3] &, {{"The first point"}, {{0., 0.}}, {{-1, -1}, {-1, -1}}}]; dimensions are 1 and 2."" – Harry Apr 18 '17 at 04:35
  • @MarcoB the output was two blue points lay as in your answer while only the second point get labeled. The whole output was covered by pink rectangle which represents error :"MapThread is not a Graphics primitive or directive " – Harry Apr 18 '17 at 04:38
  • ListPlot[{Labeled[{0, 0}, "The first point"], Labeled[{1, 1}, "The second one"]}] work well without "Left" in Mma10.0.2 on my WIN7. And your answer under https://mathematica.stackexchange.com/questions/45496/label-markers-on-listplot works well – Harry Apr 18 '17 at 04:45