Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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? –  Pickett Feb 8 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 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 at 2:50
add comment

2 Answers 2

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 = 
  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]
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 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 at 5:18
    
Thanks, this solution offers flexibility for future reference. –  Qu0rk Feb 10 at 21:20
add comment

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
add comment

Your Answer

 
discard

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.