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$
  • $\begingroup$ replace StringJoin["a", #] & /@ Map[ToString, Range[-1, 4]] with (StringJoin["a", #] & /@ Map[ToString, Range[-1, 4]])? $\endgroup$ – kglr Feb 17 at 9:17
4
$\begingroup$
SeedRandom[1]
rr = RandomReal[{-1, 1}, {6, 2}];
ListPlot[rr -> (Subscript["a", #] & /@ Range[-1, 4]), PlotStyle -> Red]

enter image description here

| improve this answer | |
$\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.