Let's see the following test case
data = Table[{RandomReal[{-10, 10}], RandomReal[{-10, 10}]}, {i, 1, 50}];
l0 = ListPlot[data, PlotStyle -> {Blue, PointSize[0.01]}];
p0 = Plot[x*Sin[x], {x, -10, 10}, PlotStyle -> {Red, Thick}];
s0=Show[{l0, p0}, Frame -> True, FrameLabel -> {"x", "y"}, Axes -> False,
GridLines -> {{1.5, 7}, {}},
GridLinesStyle -> Directive[Black,Thickness[0.004], Dashed],
Method -> {"GridLinesInFront" -> True}, PlotRange -> {{0, 10}, {-10,10}},
ImageSize -> 550]
which produces
First a minor point: Even though that I define inside Show
the plot range to be {{0,10},{-10,10}}
, we see that in the plot both axes exceed the defined limits (i.e., the -0.5 < x < 10.5 instead of [0,10]).
Now my questions:
(a). I would like to add at the position of the vertical lines on the x-axis custom labels like text "P1" and "P2".
OR
(b) Force the program to add the numbers 1.5 and 7 in the horizontal x-axis but without changing the range, I mean to keep the (0,2,4,6,8,10) and add two more inside.
Any suggestions?
PlotRangePadding->0
$\endgroup$ – Verbeia Sep 26 '14 at 11:52FrameTicks -> {{1.5, 7}~Join~Range[0, 10, 2], Automatic}
$\endgroup$ – Junho Lee Sep 26 '14 at 11:57