1. Specify Mesh as a list
ContourPlot[Cos[x] + Cos[y] == 1/2, {x, -Pi, Pi}, {y, -Pi, Pi},
MeshFunctions -> {0 &, ArcLength},
Mesh -> {Subdivide @ 3},
MeshStyle -> Directive[Red, PointSize@Large]]

Note: Curiously, if we specify the setting for Mesh
as a list of {mesh, style}
pairs we can get rid of 0&
in MeshFunctions
:
ContourPlot[Cos[x] + Cos[y] == 1/2, {x, -Pi, Pi}, {y, -Pi, Pi},
MeshFunctions -> {ArcLength},
Mesh ->
{Thread[{Subdivide@3, Directive[ Red, Opacity[1], PointSize @.03]}]}]
same picture
2. Use DisplayFunction to add the missing point
ContourPlot[Cos[x] + Cos[y] == 1/2, {x, -Pi, Pi}, {y, -Pi, Pi},
MeshFunctions -> {0 &, ArcLength},
Mesh -> 2,
MeshStyle -> Directive[Red, PointSize @ Large],
DisplayFunction -> ReplaceAll[Point@x_ :> Point[Prepend[1]@x]]]

3. Post-process to add the missing point
ReplaceAll[Point @ x_ :> Point[Prepend[1] @ x]]@
ContourPlot[Cos[x] + Cos[y] == 1/2, {x, -Pi, Pi}, {y, -Pi, Pi},
MeshFunctions -> {0 &, ArcLength},
Mesh -> 2,
MeshStyle -> Directive[Red, PointSize@Large]]

4. Use MeshStyle to add the missing mesh point
ContourPlot[Cos[x] + Cos[y] == 1/2, {x, -Pi, Pi}, {y, -Pi, Pi},
MeshFunctions -> {0 &, ArcLength},
Mesh -> 2,
MeshStyle -> ({Red, PointSize @ Large, #, Point @ 1} &)]

Update:
MeshShading
is not an option for ContourPlot
.
One way to get contours with multiple segments with different styles from ContourPlot
is to extract the line coordinates and process them with a *Plot
function that accepts MeshShading
as an option (as done in the update in OP).
In the following, we wrap all Mesh*
options (including MeshShading
) in meshOptions
and use ParametricPlot
to process them to construct the desired graphics primitives and inject them in ContourPlot
using a custom DisplayFunction
:
ClearAll[meshOptions]
meshOptions[opts : OptionsPattern[]] :=
Module[{BSF = BSplineFunction[#]},
First[Show[ParametricPlot[BSF@t, {t, 0, 1}, opts],
Graphics[{MeshStyle /. FilterRules[{opts}, MeshStyle],
Point[BSF /@ {0, 1}]}]]]] &
meshOptions /: ContourPlot[a__, meshOptions[o___], b___] :=
ContourPlot[a, b,
DisplayFunction ->
ReplaceAll[Line[x_] :> (Dynamic @ meshOptions[o] @ x)] @* Normal]
Examples:
ContourPlot[Cos[x] + Cos[y] == 1/2, {x, -Pi, Pi}, {y, -Pi, Pi},
meshOptions[
MeshFunctions -> {"ArcLength"},
Mesh -> {Subdivide @ 3},
MeshStyle -> Directive[Red, AbsolutePointSize[10]],
MeshShading -> (ColorData[97] /@ Range[3])]]

ContourPlot[{Cos[x] + Cos[y] == 1/2, Cos[x] + Cos[y] == 1,
Sin[x] + Cos[y] == 1/2}, {x, -Pi, Pi}, {y, -Pi, Pi},
PlotLegends -> "Expressions",
meshOptions[
MeshFunctions -> {"ArcLength"},
Mesh -> {Subdivide @ 3},
MeshStyle -> Directive[CurrentValue @ "Color", AbsolutePointSize[10]],
MeshShading ->
(Directive[CurrentValue @ "Color", AbsoluteDashing[3 #]] & /@ Range[3])]]

Add the option ContourStyle -> "Rainbow"
to get

{0 &, "ArcLength"}
? (I have never seen it before) $\endgroup${"ArcLength"}
. but something have been change since such version. Now we have to use twoMeshFunction
, it maybe a feature or maybe a bug. $\endgroup$