# Applying Labeled Option to Multiple Options

First post. Hope it's not ignorant. I am trying to label several data points so I can label them properly on a ListLinePlot. I know I can label plots if I am generating data, but I am dealing with experimental data.

The end goal is to be able to graph the points, and have everything labeled properly. I am trying to figure out how not to do this the "dumb" way.

Here's what I want to label:

litValues =
{"Literature Values (kcal/mol)",
123.34, 214.97, 191.35, 259.66, 335.15, 314.03, 401.75, 497.27};
plot =
ListLinePlot[{Delete[litValues, 1]},
AxesLabel -> {"Atomic number", "Ionization Energy (kj/mol)"}]


If my tone is wonky, excuse me -- I am very tired.

• Welcome to Mathematica.SE! I must admit that I don't quite understand what the question is, mostly I think because I do not know what you mean by "properly." You have already managed to have a label on the x axis and on the y axis. How do you want to change it? Feb 8 '14 at 2:27
• @Pickett I took it they wanted to put label on the points, with the value of each point. May be I also mis-understood it. Feb 8 '14 at 2:40
• @Nasser, you've got it. I would like to be able to label all of my points as they appear on the graph. Apologies for ambiguity. Feb 9 '14 at 2:50
• related Q/A: Label markers in ListPlot
– kglr
Oct 19 '14 at 22:03

if you want to label the points, one way is to build the labels yourself. (I thought there is an easier way to do this, but do not remember now). But here is an attempt

litValues = {"Literature Values (kcal/mol)", 123.34, 214.97, 191.35, 259.66,
335.15, 314.03, 401.75, 497.27};
data = Rest@litValues;
lbls = MapIndexed[Text[Style[#1, 11], {First@#2, #1}, {0, 1}] &, data];

plot =
ListLinePlot[data,
AxesLabel -> {"Atomic number", "Ionization Energy (kj/mol)"},
Mesh -> All,
ImageSize -> 500,
PlotStyle -> {Red, PointSize[0.02]},
PlotRange -> {{0, Length@data + 1}, {0.6 Min@data, 1.3 Max@data}},
Epilog -> lbls]

• How about lbls = MapThread[Text[Style[#1, 11], {#2, #1}, {0, 1}] &, {data, Range@Length@data}]? I find this a little easier to understand than MapIndexed, but perhaps that's just me. Feb 8 '14 at 5:11
• @m_goldberg yes, that is a nice way to do it as well. As typical in Mathematica, there is always at least 10 ways to do the same thing :) Feb 8 '14 at 5:18
• Thanks, this solution offers flexibility for future reference. Feb 10 '14 at 21:20

Another self made approach (using the presented data and desied labels):

ListPlot[txt = Rest@litValues, Joined -> True,
Epilog -> (Text[#[[2]], # + {0, 20}] & /@
Transpose[{Range[Length@txt], txt}]),
PlotMarkers -> { Automatic, 8},
BaseStyle -> {FontFamily -> "Kartika", 16},
PlotRange -> {{0, 9}, {0, 600}}, Frame -> True,
FrameTicks -> {Range[8], Automatic, None, None},
FrameLabel -> {"Atomic Number", "Ionization Energy"},ImageSize->600]


Update: Callout in versions 11.0+:

ListLinePlot[Callout[#, #]& /@ (Rest @ litValues),
AxesLabel -> {"Atomic number", "Ionization Energy (kj/mol)"},
ImageSize -> 500, PlotStyle -> Red, PlotMarkers -> {Automatic, 14}]


You can also pre-process the data to style and label it:

labeleddata = Labeled[#, Style[#, 11], Below] & /@ Rest[litValues];

ListLinePlot[labeleddata,
AxesLabel -> {"Atomic number", "Ionization Energy (kj/mol)"},
ImageSize -> 500, PlotStyle -> Red, PlotMarkers -> {Automatic, 14},
PlotRange -> {{0, Length@labeleddata + 1}, {0.6 Min@Rest[litValues], Automatic}}]


Or, put the labels After the plotmarkers using

labeleddata = Labeled[#, Style[#, 11], After] & /@ Rest[litValues];


When used without a position specification, Labeled positions the labels in a way to avoid collisions (see this answer by @Mr.Wizard to a closely related question):

labeleddata = Labeled[#, Style[#, 11]] & /@ Rest[litValues];