# How to mark a specific line in ContourPlot

I have the next differential equation

sol = ParametricNDSolve[{y'[t] == a y[t], y[0] == 1}, y, {t, 0, 10}, {a}]


And a Contour Plot of this equation

 ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4},
PlotLegends -> BarLegend[Automatic,
LegendMarkerSize -> 180,   LegendFunction -> "Frame", LegendMargins -> 5,
LegendLabel -> "y[a][x]"], Frame -> True,  FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14}]


With this code, I obtain the next image

I would like to mark the line of constant value $$1.5$$. To mark this line I click on the line, but I would like to obtain something more "elegant"

EDIT

There is a way of isolate that specific line? I mean getting something like this:

Clear["Global*"]

sol = ParametricNDSolve[{y'[t] == a y[t], y[0] == 1}, y, {t, 0, 10}, {a}];

Show[
ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4},
PlotLegends -> BarLegend[Automatic,
LegendMarkerSize -> 180,
LegendFunction -> "Frame",
LegendMargins -> 5,
LegendLabel -> "y[a][x]"],
Frame -> True,
FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14}],
ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4},
Contours -> {1.15},
ContourStyle -> Directive[Thick, White],


Or

ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4},
PlotLegends -> BarLegend[Automatic,
LegendMarkerSize -> 180,
LegendFunction -> "Frame",
LegendMargins -> 5,
LegendLabel -> "y[a][x]"],
Frame -> True,
FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14},
Contours -> Range[1.05, 1.45, 0.05],
ContourStyle -> ReplacePart[
Array[Black, 9],
3 -> Directive[Thick, Opacity[1, White]]]]


• I think that your answer, solve both of the problems, I mean the original question and the edit of the question, thank you. May 18, 2020 at 17:57

  sol = ParametricNDSolve[{y'[t] == a y[t], y[0] == 1},
y, {t, 0, 10}, {a}];
ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4}, Frame -> True,
FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14},
Contours -> {1.15}, ContourStyle -> Directive[Thick, Red],


Woudl this work?

ContourPlot[
y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4},
PlotLegends ->
BarLegend[Automatic, LegendMarkerSize -> 180,
LegendFunction -> "Frame", LegendMargins -> 5,
LegendLabel -> "y[a][x]"],
Frame -> True, FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14},

Contours -> {{1.15, Thick}}, ContourShading -> None
]


1. You can use MeshFunctions + Mesh:

ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4},
MeshFunctions -> {y[a][x] /. sol /. {x -> #, a -> #2} &},
Mesh -> {{{1.15, Directive[Opacity[1], Thick, White]}}},
PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> 180,
LegendFunction -> "Frame", LegendMargins -> 5,
LegendLabel -> "y[a][x]"], Frame -> True,
FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14}]


Alternatively, you can use Mesh -> {{1.15}} and add the option MeshStyle -> Directive[White, Thick] to get the same picture.

A slightly more convenient approach is to use ParametricNDSolveValue instead of ParametricNDSolve:

pndsv = ParametricNDSolveValue[{y'[t] == a y[t], y[0] == 1}, y, {t, 0, 10}, {a}];

ContourPlot[pndsv[a][x], {x, 0, 0.1}, {a, 0, 4},
MeshFunctions -> {pndsv[#2][#] &},
Mesh -> {{{1.15, Directive[Opacity[1], Thick, White]}}},
PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> 180,
LegendFunction -> "Frame", LegendMargins -> 5,
LegendLabel -> "y[a][x]"], Frame -> True,
FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14}]


same picture

2. You can post-process ContourPlot output to change the directives for the desired contour line:

cp = ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4},
PlotLegends ->  BarLegend[Automatic, LegendMarkerSize -> 180,
LegendFunction -> "Frame", LegendMargins -> 5,
LegendLabel -> "y[a][x]"], Frame -> True,
FrameLabel -> {{"a", ""}, {"x", ""}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 14}];

cp /.  t : Tooltip[_, 1.15] :>
(t /. {Opacity[_] -> Opacity[1], GrayLevel[0] -> Directive[Thick, White]})
`