# How to add contour labels for contour lines?

How can I add contour labels to contour lines? The usual ContourLabels->Automatic doesn't seem to be working when the input is given in the third form of ContourPlot.

labelFontSize = 24;
ticksFontSize = 16;
lineThickness = 2;

contourPlotToF = ContourPlot[
tArrival - tDeparture == Table[Δt, {Δt, 0, 70, 7}],
{tDeparture, 30, 60}, {tArrival, 30, 60},
ImageSize -> Full,
FrameLabel -> {Row[{"Departure time/", Quantity[None, "Days"]}],
Row[{"Arrival time/", Quantity[None, "Days"]}]},
FrameTicksStyle -> Directive[FontSize -> ticksFontSize],
LabelStyle -> {FontSize -> labelFontSize},
ContourLabels -> Automatic,
ContourStyle -> {Directive[
ColorData[97, "ColorList"][[4]],
AbsoluteThickness[lineThickness]]},
GridLines -> Automatic
]


Edit:

As per @Michael E2 suggestion, I've altered

tArrival - tDeparture == Table[Δt, {Δt, 0, 70, 7}],


to

Evaluate[Thread[tArrival-tDeparture==Table[Δt,{Δt, 0, 70, 7}]]],


which is producing the following result:

The label is appearing only when I hover the line, and just giving the list of contours. What I use for "traditional" contour plots is

ContourLabels -> (Text[Style[#3, ticksFontSize], {#1, #2}] &),


for the labels to appear next to the lines. However, this doesn't seem to work here.

PS: By "traditional" contour plots, I mean of the first form of ContourPlot, with the colour coded in-between contours.

• The third form, strictly speaking, is given by ContourPlot[Evaluate[Thread[tArrival - tDeparture == Table[\[CapitalDelta]t, {\[CapitalDelta]t, 0, 70, 7}]]],...]. The labels and styling of plots come from the given form, before it is processed for plotting. – Michael E2 Sep 20 '20 at 16:54
• @BobHanlon That way I get a "traditional" contour plot, whereas I want only the lines... – Jak Sep 21 '20 at 11:57
• @MichaelE2 Thank you for the correction. Still, the labels are only appearing when I hover, and are the same for every contour (I edited the question to include what I'm getting). Is it possible to add each contour value next to the line? The code I use for "traditional" contour plots does not work here (also included in the edit). – Jak Sep 21 '20 at 12:03
• When the input is in the form of an equation, either the second or third paradigm in the docs, ContourPlot treats the equation as the label. Since the numerical value on each side of an equation may vary along the solution curve, the value is not treated as significant. I think @Bob's approach can probably be adapted to your needs more easily than using the third form. – Michael E2 Sep 21 '20 at 13:04
• – Michael E2 Sep 21 '20 at 13:43

Alternatively, use the first form

Clear["Global*"]

labelFontSize = 24;
ticksFontSize = 16;
lineThickness = 2;

ContourPlot[tArrival - tDeparture,
{tDeparture, 30, 60}, {tArrival, 30, 60},
Contours -> Range[0, 70, 7],
ImageSize -> Medium,
FrameLabel -> {
Row[{"Departure time/", Quantity[None, "Days"]}],
Row[{"Arrival time/", Quantity[None, "Days"]}]},
FrameTicksStyle -> Directive[FontSize -> ticksFontSize],
LabelStyle -> {FontSize -> labelFontSize},
ContourLabels ->
(Text[Framed[#3], {#1, #2}, Background -> White] &),
ContourStyle ->
Directive[ColorData[97, "ColorList"][[4]], AbsoluteThickness[lineThickness]],
`