Why don't I see all the grid lines in my combined contour plots?

I am trying to display four continuous functions, but when I try to combine them withe a single Show, I can't see the second vertical line. I suppose the problem is with the GridLines.

The code is:

j = -1;
a2 = 3.968342707518218;
a1 = 3.275794729726671;
NalfaF = -0.749964;
alfaF1 = 0.749964;
mu = 10^-3;
Ntot = NalfaF*mu;
tot1 = alfaF1*mu;
alfaF2 = 1.54553;
tot2 = alfaF2*mu;
k =
Show[ContourPlot[(Sqrt[(16 tot1 y)/3 (1 + tot1/(27 y^3))] - (
2 tot1)/(9 j y)) (x - 0.95 a1) == 0.002, {x, -10, 10}, {y,
0, .3}, PlotRange -> {{2.50, 4.5}, {0., 0.3}},
ContourShading -> None, PlotPoints -> 100,
Epilog -> {AbsolutePointSize[8], Text["2:1", {a1 + 0.1, 0.01}],
Black, Point[{a1, 0.}]}, GridLines -> {{a1}, {}}],
ContourPlot[(-Sqrt[(16 tot1*y)/3 (1 + tot1/(27 y^3))] - (2 tot1)/(
9 j y)) (x - 1.17 a1) == 0.004, {x, -10, 10}, {y, 0, .3},
PlotRange -> {{2.50, 4.5}, {0., 0.3}}, ContourShading -> None,
GridLines -> {{a1}, {}}, PlotPoints -> 100,
Epilog -> {AbsolutePointSize[8], Text["2:1", {a1 + 0.1, 0.01}],
Black, Point[{a1, 0.}]}],
ContourPlot[(Sqrt[(16 tot2 y)/3 (1 + tot2/(27 y^3))] - (2 tot2)/(
9 j y)) (x - 0.95 a2) == 0.002, {x, -10, 10}, {y, 0, .3},
PlotRange -> {{2.50, 4.5}, {0., 0.3}}, ContourShading -> None,
PlotPoints -> 100,
Epilog -> {AbsolutePointSize[8], Text["3:2", {a2 + 0.1, 0.01}],
Black, Point[{a2, 0.}]}, GridLines -> {{a2}, {}}],
ContourPlot[(-Sqrt[(16 tot2*y)/3 (1 + tot2/(27 y^3))] - (2 tot2)/(
9 j y)) (x - 1.1 a2) == 0.004, {x, -10, 10}, {y, 0, .3},
PlotRange -> {{2.50, 4.5}, {0., 0.3}}, ContourShading -> None,
GridLines -> {{a2}, {}}, PlotPoints -> 100,
Epilog -> {AbsolutePointSize[8], Text["3:2", {a2 + 0.1, 0.01}],
Black, Point[{a2, 0.}]}]]


How can I make sure both vertical lines show?

The issue is not GridLines itself. The issue is that when you have different values for the same options across multiple plots in a Show, the option values specified in the first plot prevail.

Merging the GridLines and Epilog option values into the first plot will vastly simplify your code:

k = Show[ContourPlot[(Sqrt[(16 tot1 y)/
3 (1 + tot1/(27 y^3))] - (2 tot1)/(9 j y)) (x - 0.95 a1) ==
0.002, {x, -10, 10}, {y, 0, .3},
PlotRange -> {{2.50, 4.5}, {0., 0.3}}, ContourShading -> None,
PlotPoints -> 100,
Epilog -> {AbsolutePointSize[8], Text["2:1", {a1 + 0.1, 0.01}],
Text["3:2", {a2 + 0.1, 0.01}], Black, Point[{a2, 0.}],
Point[{a1, 0.}]}, GridLines -> {{a1, a2}, {}}],
ContourPlot[(-Sqrt[(16 tot1*y)/
3 (1 + tot1/(27 y^3))] - (2 tot1)/(9 j y)) (x - 1.17 a1) ==
0.004, {x, -10, 10}, {y, 0, .3}, ContourShading -> None,
PlotPoints -> 100],
ContourPlot[(Sqrt[(16 tot2 y)/
3 (1 + tot2/(27 y^3))] - (2 tot2)/(9 j y)) (x - 0.95 a2) ==
0.002, {x, -10, 10}, {y, 0, .3}, ContourShading -> None,
PlotPoints -> 100],
ContourPlot[(-Sqrt[(16 tot2*y)/
3 (1 + tot2/(27 y^3))] - (2 tot2)/(9 j y)) (x - 1.1 a2) ==
0.004, {x, -10, 10}, {y, 0, .3}, ContourShading -> None,
PlotPoints -> 100]]


Here is a simpler example to make it clear what is going on:

Show[Plot[Sin[x], {x, 0, 6}, PlotRange -> {-2, 2}, PlotStyle -> Green],
Plot[Cos[2 x], {x, 0, 6}, PlotRange -> {-1, 1}]]


As you can see, PlotStyle doesn't propagate to both plots, because it is a characteristic of the line, while PlotRange does, because it is a characteristic of the plot, if that makes sense.

• FYI I'm getting Power::infy errors from this code (combined with the OP's) but I'm too lazy to check why. Commented Apr 4, 2013 at 23:55