Search code examples
plotwolfram-mathematicaaxis-labelsmathematica-8gridlines

Plotting multiple gridlines and give seperate labels in Mathematica


I am trying to make the following plot:

Pars = {ep -> 0.5, f1p -> 0.3, f2p -> 0.1, dp -> 0.05, q -> 0.1, 
   en -> 0.4, d -> 0.1, Q -> 0.1, f2n -> 0.3, f1n -> 0.4, a -> 0.05, 
   N1 -> 0.5, N2 -> 0.5}; #Parameters

PlotREq1 = 
  Plot[R = S /. Pars, {S, 0, 0.9375}, 
   PlotRange -> {{0, 3.5}, {0, 2}}, PlotStyle -> {Red, Thick, Dashed},
    GridLines -> {{0.9375}, {}}];  
PlotREq2 = 
  Plot[R = (a + d)/(en f1n) /. Pars, {S, 0.9375, 1.4375}, 
   PlotRange -> {{0, 3.5}, {0, 2}}, PlotStyle -> {Red, Thick, Dashed},
    GridLines -> {{1.4375}, {}}];
PlotREq3 = 
  Plot[R = ((a + d) (f1p - f2p))/(en (f1p f2n - f1n f2p)) /. Pars, {S,
     1.4375, 2.3}, PlotRange -> {{0, 3.5}, {0, 2}}, 
   PlotStyle -> {Red, Thick, Dashed}, GridLines -> {{2.3}, {}}];
Show[PlotREq1, PlotREq2, PlotREq3]

However, only the first gridline shows up and the other two vertical lines at 1.4375 and 2.3 do not appear. Also, can anyone suggest a way to label the gridlines? I tried to insert a axeslabel within the Gridline function as: Gridlines -> {{{0.9375},{}}, AxesLabel -> {"R",""}} but it does not seem to work.


Solution

  • Using Show, only the first version of an option is followed. Place all the gridlines in the first plot, or add them as options to Show, which will override any others.

    Show[PlotREq1, PlotREq2, PlotREq3, GridLines -> {{0.9375, 1.4375, 2.3}, {}}]