turn off antialiasing

Hi, is it possible to turn off antialiasing for the

    > axes and labels of a plot, or does it affect the data
    > only?

Yes and no.

You can turn off antialiasing by default for all lines and patches
(which includes the axes frame since the frame is a Rectangle which
derives from Patch in matplotlib.patches) by setting

lines.antialiased : False
patch.antialiased : False

in your matplotlibrc file http://matplotlib.sf.net/.matplotlibrc. You
can also do this for an individual script using the rc command -
http://matplotlib.sf.net/matplotlib.matlab.html#-rc.

If you only want to selectively turn off antialiasing for the axes
lines and rectangle, you can set the antialised property to False for
all the relevant objects

  from matplotlib.matlab import *

  ax = subplot(111)
  plot([1,2,3])
  grid(True)
  objects = (ax.get_xticklines() + ax.get_yticklines() +
             ax.get_xgridlines() + ax.get_ygridlines() +
             [ax.get_frame()]
             )
  set(objects, antialiased=False)

  show()

As for text, assuming you are using one of the *Agg backends, you
cannot get aliased text. agg uses the freetype module ft2font for
text rendering. Off the top of my head, I don't know if freetype has
an aliased option (Anyone?), and I know the matplotlib wrapper doesn't
currently support it if it does.

You always have the option of using a backend that doesn't support
antialiasing (eg wx, ps), but most of them do in some regard; eg gtk
uses antialiased text but not lines, I believe.

What do you want this feature - is it because it doesn't look nice in
printouts of agg PNGs (this has come up before)? If so, and you have
a postscript printer, that may be your best bet. You could also try
the SVG output, for which there are plugins or programs that would
probably know how to send an svg doc to your printer.

JDH

John Hunter wrote:

What do you want this feature - is it because it doesn't look nice in
printouts of agg PNGs (this has come up before)? If so, and you have
a postscript printer, that may be your best bet. You could also try
the SVG output, for which there are plugins or programs that would
probably know how to send an svg doc to your printer.

In fact the PNGs are looking too nice. I want to create a GIF animation to be included in a p0werpoint presentation. As p0werpoint automatically does antialiasing for every bitmap graphic it produces ugly results if the bitmap is already antialised. Anyway, it's not that important...

Christian