1
$\begingroup$

I have plot a list of points by ListPlot, and I want to be able to label these points.

Basic codes:

ListPlot[RandomReal[{-1, 1}, {6, 2}] -> ToString /@ Range[-1, 4], PlotStyle -> {Red}]

Now I want the label style like "a1, a2, ..."(Subscript is best), I changed the codes

ListPlot[RandomReal[{-1, 1}, {6, 2}] -> StringJoin["a", #] & /@ Map[ToString, Range[-1, 4]], PlotStyle -> {Red}]

but there is no point was labeled, I don't know why, the String list length still 6 (Length[StringJoin["a", #] & /@ Map[ToString, Range[-1, 4]]]), how does it show the labels?

$\endgroup$
1
  • $\begingroup$ replace StringJoin["a", #] & /@ Map[ToString, Range[-1, 4]] with (StringJoin["a", #] & /@ Map[ToString, Range[-1, 4]])? $\endgroup$
    – kglr
    Feb 17, 2020 at 9:17

1 Answer 1

4
$\begingroup$
SeedRandom[1]
rr = RandomReal[{-1, 1}, {6, 2}];
ListPlot[rr -> (Subscript["a", #] & /@ Range[-1, 4]), PlotStyle -> Red]

enter image description here

$\endgroup$

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.