Message Boards Message Boards

0
|
52 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Gridlines extending to plotting range not the specified gridline range

Posted 15 hours ago

Hello Is there are way to get gridlines to extend only as far as the gridline specification rather than extending to the plotting range. For example, the following code:

    Plot[Sin[x], {x, -10, 10},
     PlotRange -> {{-12, 12}, {-12, 13}},
     AxesLabel -> {x, y},
     LabelStyle -> 
      Directive[Black, 14, Italic, FontFamily -> "Times New Roman"],
     AxesStyle -> Arrowheads[{0.1, 0.03}],
     GridLines -> {Range[-10, 10, 1], Range[-10, 10, 1]},
     GridLinesStyle -> Directive[Gray, Normal],
     Ticks -> {{-10, -5, 5, 10}, {-10, -5, 5, 10}},
     TicksStyle -> 
      Directive[Black, Plain, 12, FontFamily -> "Times New Roman", 
       Background -> Directive[Opacity[0.75], White]],
     Epilog -> 
      Text[Style["O", Italic, FontSize -> 12, 
        FontFamily -> "Times New Roman"], {0.5, 0.75}]
     ]

yields the plot where the gridlines extend beyond the 10-by-10 grid specified (see plot below).

TIA Geoffrey

POSTED BY: Geoffrey Marnell

As a workaround, you can make your own custom grid:

Prolog -> {Gray, Thin,
  Table[{Line[{{{n, -10}, {n, 10}},
      {{-10, n}, {10, n}}}]},
   {n, -10, 10}]}
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract