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?
The gory details:
(1) This is a self-compiled version of matplotlib-0.86.2 on a Debian
Sarge system. I used the following options in setup.py.
rc = dict({'backend':'Agg', 'numerix':'numarray'})
BUILD_IMAGE = 1
BUILD_AGG = 1
BUILD_GTKAGG = 0
BUILD_GTK = 0
BUILD_TKAGG = 0
BUILD_WXAGG = 0
BUILD_WINDOWING = 0
(2) The following code was used to generate the picture:
import matplotlib
matplotlib.use("Agg")
from pylab import *
from matplotlib.dates import DayLocator, WeekdayLocator, DateFormatter, \
date2num
...prepare the data...
rc('xtick',labelsize=9)
rc('ytick',labelsize=9)
figure(figsize=(7,5),dpi=100)
axes([0.07, 0.58, 0.89, 0.36])
ax = gca()
fill(k+k[::-1], xv+xs[::-1], fc="g", ec="g")
fill(k+[k[-1],k[0]], xs+[0,0], fc="r", ec="r")
ax.xaxis.set_major_locator(WeekdayLocator(byweekday=SU))
ax.xaxis.set_major_formatter(NullFormatter())
ax.xaxis.set_minor_locator(DayLocator())
ax.autoscale_view()
grid(True)
axes([0.07, 0.20, 0.89, 0.36])
ax = gca()
fill(k+k[::-1], yv+ys[::-1], fc="g", ec="g")
fill(k+[k[-1],k[0]], ys+[0,0], fc="r", ec="r")
ax.xaxis.set_major_locator(WeekdayLocator(byweekday=SU))
ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
ax.xaxis.set_minor_locator(DayLocator())
ax.autoscale_view()
grid(True)
labels = ax.get_xticklabels()
setp(labels, rotation=90)
savefig("spamdiag.png",dpi=100)
(3) You can see the resulting picture at
http://seehuhn.de/comp/spam.html#fig1
The problem seems to occur at every second horizontal grid line in
the lower panel.
Many thanks,
Jochen