# Rotating Label inside ListLinePlot

I would like to label a curve inside ListLinePlot. Let's say I have the following list:

Table[{x, x^2}, {x, 0, 10, 0.1}]


What I expected is a labeled curve. The label should also be placed above the curve and in the middle. It should also be rotated with the curve like the following picture.

But if I try the following code with ListLinePlot and Labeled:

ListLinePlot[Labeled[Table[{x, x^2}, {x, 0, 10, 0.1}], "x^2", {Top, Center}]]


And I get the following error:

Labeled::labpos: {{Top,Center}} is not a valid position for the placement of labels.


How can I do it properly?

In Version 11.0.1, Labeled can be used in the dataset level.

data = Table[{x, x^2}, {x, 0, 10, 0.1}];
ListLinePlot[Labeled[data, Style[Rotate[x^2, 40 Degree], Bold, 14], {6, 42}]]


The third argument of Labeled in this case is a precise location.

To use Labeled to make the kind of label you want, you have to wrap a specific point with Labeled. You also have to use Rotate to get the rotation.

Here is the code:

data = Table[{x, x^2}, {x, 0, 10, 0.1}];
data[[61]] = Labeled[data[[61]], Rotate[Style[x^2, 14, Bold], 40 °]];
ListLinePlot[data]


data[[61]] is the point {6., 36.}

### Update

You can nudge the label with Labeled's 3rd argument. In the following example, I have moved the label somewhat closer to the curve.

data = Table[{x, x^2}, {x, 0, 10, 0.1}];
data[[61]] = Labeled[data[[61]], Rotate[Style[x^2, 14, Bold], 40 °], {.7, 0}];
ListLinePlot[data]


• Thanks! That's quite what I wanted. But I think the label is a little to far away from the curve. Is there any way to make it a little bit nearer? – 407PZ Jan 15 '17 at 10:28

Use Text or Inset in Epilog:

ListLinePlot[Table[{x, x^2}, {x, 0, 10, 0.1}],
Epilog -> Text[Style[x^2, 15], {4.5, 25}, Automatic, {1, .6}]]


or

ListLinePlot[Table[{x, x^2}, {x, 0, 10, 0.1}],
Epilog -> Text[Style["x^2", 15], {4.5, 25}, Automatic, {1, .6}]]


depending on whether you want to math-format the exponent.

• Shouldn't one of these examples demonstrate the use Inset? – m_goldberg Jan 15 '17 at 0:19