1
$\begingroup$

Is there a way more convenient to position the text beside the circles. How can I do this in automatic mode?

data = {{0, 2}, {4, 5}, {8, 7}, {10, 25}}
Graphics[{PointSize[0.1],
Point[data],
Text[Style["0,2",
FontSize -> 20, Bold, Red], {0, 2}, {2, 0}],
Text[Style["4,5", FontSize -> 20, Bold, Red], {4, 5}, {2, 0}],
Text[Style["8,7", FontSize -> 20, Bold, Red], {8, 7}, {2, 0}], 
Text[Style["10,25", FontSize -> 20, Bold, Red], {10, 25}, {2, 0}]}]
$\endgroup$
2
$\begingroup$

Try this:

data = {{0, 2}, {4, 5}, {8, 7}, {10, 25}}

Graphics[{PointSize[0.1],
  Point[data],
  Text[Style[{data[[1, 1]], data[[1, 2]]}, FontSize -> 20, Bold, 
    Red], {data[[1, 1]], data[[1, 2]]}, {2, 0}], 
  Text[Style[{data[[2, 1]], data[[2, 2]]}, FontSize -> 20, Bold, 
    Red], {data[[2, 1]], data[[2, 2]]}, {2, 0}], 
  Text[Style[{data[[3, 1]], data[[3, 2]]}, FontSize -> 20, Bold, 
    Red], {data[[3, 1]], data[[3, 2]]}, {2, 0}], 
  Text[Style[{data[[4, 1]], data[[4, 2]]}, FontSize -> 20, Bold, 
    Red], {data[[4, 1]], data[[4, 2]]}, {2, 0}]}]
$\endgroup$
  • $\begingroup$ I will try to do this... $\endgroup$ – JPeter Sep 24 '16 at 19:42
4
$\begingroup$
pts = {{0, 2}, {4, 5}, {8, 7}, {10, 25}};
fmt = StringTemplate["``,``"];
texts = {Red, 
     Text[Style[fmt @@ #, Bold, FontSize -> 20], #, {2, 0}]} & /@ pts;
Graphics[{PointSize[0.1], Point[pts], texts}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.