a function to prevent "overdraw" of minor ticks/gridlines

I've attached a small demo code that solves a problem I was having;
when the grid for the major and minor ticks are both drawn, the minor
grid is drawn over the top of the major grid. This can make the grid
at the majors look a little messy. The same thing was happening for
the ticks as well; minor ticks are drawn on top of major.

I'm hoping that someone will find the attached code useful, and also
that it might make its way into matplotlib. The
"set_superior_locator" function in the attached code would be a very
natural fit inside the Locator class as a member function, with hardly
any modification.

All the set_superior_locator() function does is to inject itself into
the Locator object, so that it gets a chance to cull out locations
that are duplicated between it and its "superior" locator. The main
use of this is to tell a minor locator who the major locator is, so
that the minor locator will not draw ticks and/or grid lines on top of
places where the major locator has already done it.

If you run the script attached, it will pop two plots (close one to
see the other); one with default drawing, and the second with the
culling of grid lines and tick marks. I know that the colors and
thicknesses that I chose are ugly, but they do illustrate the point :wink:

griddemo.py (3.45 KB)


Daniel Hyams