7
$\begingroup$

I want to add a label to each point of my ListPlot[] by using the example from the documentation as a basis:

ListPlot[Labeled[#, #] & /@ Table[Prime[n], {n, 10}], 
         PlotStyle -> PointSize[Medium]]

ListPlot labels

Now I want to increase the spacing of the labels. Labeled[] has the option Spacings for this, but unfortunately, I can't combine them with my plot:

ListPlot[Labeled[#, #, Spacings -> {1, 1}] & /@ 
         Table[Prime[n], {n, 10}], PlotStyle -> PointSize[Medium]]

because it results in the following error:

Labeled::labpos: "Spacings->{1,1} is not a valid position for the placement of labels. "

Is there any way around this problem?

Tested with Mathematica 10.4.1.

$\endgroup$
1
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Commented Jul 11, 2016 at 18:17

1 Answer 1

6
$\begingroup$

The 3rd position of Labeled is position and dosn't require Spacings.

shiftX = -2;
shiftY = -0.6;

ListPlot[Table[Labeled[Prime[n], Prime[n], {-shiftX, -shiftY}], {n, 10}], DataRange -> All]

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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