problem with "fuzzy" grid lines

Hello, I use matplotlib to non-interactively convert a

    > pile of numbers into a diagram for may web page. My
    > problem: the resulting grid lines are not perfectly
    > straight, they seem to be undecided which of two pixel
    > rows they belong to. The lines (magnified and in ASCII
    > art) look a bit like

    > ******** ******** ****
    > ******** ******** ****** ****

    > How can I get straight and homogeneous lines?

Yes, that is annoying. I just made some changes to CVS to fix it. The
root of the problem is that Agg does subpixel rendering. I have some
hacks now to make it work right for grid lines, but a cleaner approach
would be to expose "use subpixel" to the GC, and allow the grid lines
to turn it off.

Checking in src/_backend_agg.cpp;
/cvsroot/matplotlib/matplotlib/src/_backend_agg.cpp,v <--
_backend_agg.cpp
new revision: 1.98; previous revision: 1.97

JDH

Hello John,

Yes, that is annoying. I just made some changes to CVS to fix it. The
root of the problem is that Agg does subpixel rendering. I have some
hacks now to make it work right for grid lines, ...

Sorry for the delay. I tried it now and it does NOT work :frowning:
The diagram on the web page is now generated with the current
CVS version of matplotlib, but the problem still persists.

I uncommented the

    std::cout << "snapto "<<thisx<<" "<<thisy<<std::endl;

line in _backend_agg.cpp and found that this bit of code is only
called 142 times, which is significantly less than the number of
grid line fragments.

I tried to change (in RendererAgg::draw_lines) the test

    snapto = (x0==x1) || (y0==y1);

(looked dangerous to me, these are doubles) into

    snapto = fabs(x0-x1)<1e-6 || fabs(y0-y1)<1e-6 ;

but this did not help.

Any more ideas?

Many thanks,
Jochen

···

On Sun, Jan 29, 2006 at 10:58:50AM -0600, John Hunter wrote:
--