Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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? – C. E. 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. – Nasser 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. – Qu0rk Feb 9 '14 at 2:50
related Q/A: Label markers in ListPlot – kglr Oct 19 '14 at 22:03
up vote 3 down vote accepted

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

Mathematica graphics

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 = 
    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]
share|improve this answer
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. – m_goldberg 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 :) – Nasser Feb 8 '14 at 5:18
Thanks, this solution offers flexibility for future reference. – Qu0rk 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]

enter image description here

share|improve this answer

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

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

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

enter image description here

Or, put the labels After the plotmarkers using

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

enter image description here

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];

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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