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.
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. $\endgroup$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. $\endgroup$