# How to print coordinates above certain points

How do I place the x and y values of the points I have found (maxandmindistance) above the point in a plot?

Here is my code so far:

Distance[t_] := t*(t - 1)*(t - 1.5)^2*(t - 3)
Velocity[t_] := Simplify[Distance'[t]]
maxandmindistance = Solve[Velocity[t] == 0, t]
Show[Plot[Distance[t], {t, 0, 3}],
Graphics[{Red, PointSize[Large],
Point[{t, Distance[t]} /. maxandmindistance]}]]


This results in a function with dots along it. They are the maximum and minimum values for the function. The problem is that the coordinates (x,y values) are not shown.

-
Can you explain clearly what you expect and what happens instead? – halirutan Nov 15 '12 at 9:48
Apologies. I end up with a line function with dots along it. They are the maximum and minimum values for the function. The problem is that the coordinates (x,y values) are not shown. – General Stubbs Nov 15 '12 at 9:51

Did you mean this?

Distance[t_] := t*(t - 1)*(t - 1.5)^2*(t - 3)
Velocity[t_] := Simplify[Distance'[t]]
maxandmindistance = Solve[Velocity[t] == 0, t];
coords = # + Chop[#2 - #] &[Round@#, #] &@({t, Distance[t]} /.
maxandmindistance);
Show[Plot[Distance[t], {t, 0, 3},
PlotRange -> {{0, 3.5}, {-2.5, 1.5}}],
Graphics[{Red, PointSize[Large],
Point[{t, Distance[t]} /. maxandmindistance],
Table[{Black, Text[ToString[coords[[i]]], coords[[i]] + .3]}, {i,
Length[coords]}]
}]]


If needed, you can also double-click on the image and adjust the formatting and the position of each text label to obtain the output you like most.

-
When I entered that in and stretched the graph so that the text did not overlap, the co ordinates just left. They were not attached to the point. – General Stubbs Nov 15 '12 at 10:14
@GeneralStubbs What do you mean with "stretched the graph"? – VLC Nov 15 '12 at 10:17
I took one of the corners of the plot and extended it making it larger. – General Stubbs Nov 15 '12 at 10:18
@GeneralStubbs It doesn't happen to me. The text is defined to be at the same coordinates as the red points plus a shift of .3 to the right and upwards, so it always moves in sync with the red points when stretching the image. – VLC Nov 15 '12 at 10:25
@GeneralStubbs See the update on how to manually adjust the position of the text labels. – VLC Nov 15 '12 at 10:35