1
$\begingroup$

I use listlineplot to plot some datasets and I don't know why a horizontal line appears in the plot which is when U is approximately 5. I want to omit the line which in the output of the below lines

    L = 20;

lst1 = {0.01564344653109275, 0.030901699458882034, 
   0.04539904998944419, 0.05877852523891589, 0.07071067812285757, 
   0.08090169943684067, 0.08910065241415929, 0.09510565162182796, 
   0.09876883404996432, 0.0999999999898204, 0.09876883404996355, 
   0.09510565162182645, 0.08910065241415803, 0.08090169943683993, 
   0.07071067812285665, 0.05877852523891543, 0.04539904998944429, 
   0.03090169945888173, 0.015643446531092838` };
p1 = ListLinePlot[-2 Log[lst1/Total[lst1]], DataRange -> {1, L - 1}/L,
    PlotStyle -> {Black, Dashed, Thickness[0.003]}, 
   PlotLegends -> {"q = r = 2"}];

lst2 = {0.010814123835564406, 0.02131436441316639, 
   0.03830237328244655, 0.05417864410963838, 0.06848236330194081, 
   0.08079836105637143, 0.09076916178965738, 0.09810535997584019, 
   0.10259402022974776, 0.10410485782135909, 0.10259402022974679, 
   0.09810535997583723, 0.09076916178965475, 0.08079836105636874, 
   0.06848236330193896, 0.05417864410963691, 0.0383023732824455, 
   0.021314364413165778, 0.010814123835564201` };
p2 = ListLinePlot[-2 Log[lst2/Total[lst2]], DataRange -> {1, L - 1}/L,
    PlotStyle -> {Red, Thickness[0.003]}, 
   PlotLegends -> {"q < r (q = 1.2 , r = 3.5)"}];

Show[{p1, p2}, Frame -> True, 
 PlotRange -> {{1, L - 1}/L, {4.5, 10}}, PlotLabel -> "L = 20", 
 FrameLabel -> {Style["\!\(\*FractionBox[\(l\), \(L\)]\)", 14, Bold], 
   Style["U", 14, Bold]}]
Export["L20.pdf", %, ImageSize -> 100]

How can I do that? What is it there for?

$\endgroup$
  • 1
    $\begingroup$ What happens if you add Axes -> None? $\endgroup$ – J. M. will be back soon Oct 6 '18 at 13:45
  • 1
    $\begingroup$ I think you want Axes->False on the p1 plot $\endgroup$ – mikado Oct 6 '18 at 16:39
  • 1
    $\begingroup$ Setting Axes -> False within the Show command also works. Evidently, Frame -> True does not automatically override the Axes - True option carried by p1 into Show. Instead, the Axes and Frame commands somehow interact to create the spurious horizontal line. I think this is a bug. $\endgroup$ – bbgodfrey Oct 6 '18 at 16:59
  • 1
    $\begingroup$ @bb, it's not really a bug; just something that the user doesn't want in this case. One may still want a plot with both axes and a frame; e.g. Plot[Sin[x], {x, -3, 3}, Axes -> True, Frame -> True] $\endgroup$ – J. M. will be back soon Oct 6 '18 at 18:51
  • 1
    $\begingroup$ @bbgodfrey - I do not agree that this shows a bug. Since Frame and Axes are controlled independently, putting Frame -> True in the Show has no effect on the default Axes -> True inherited from p1. However, since "Options explicitly specified in Show override those included in the graphics expression" then either Axes -> False or Axes -> None in the Show will override the default Axes setting from p1. $\endgroup$ – Bob Hanlon Oct 6 '18 at 18:58
2
$\begingroup$
Show[{p1, p2}, Frame -> True, PlotRange -> {{1, L - 1}/L, {4.5, 10}}, 
 PlotLabel -> "L = 20", 
 FrameLabel -> {Style["\!\(\*FractionBox[\(l\), \(L\)]\)", 14, Bold], 
   Style["U", 14, Bold]}, Axes -> None]

yields the following

enter image description here

Have fun!

$\endgroup$
  • $\begingroup$ How easy! thanks a lot!!! $\endgroup$ – sara kaviani Oct 7 '18 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.