antialiased pyplot, anyone interested? (code attached)

Hello List,

Just had a go at using the wx.GCDC class with pyplot (the little plot module which comes with wxPython). Result is nice antialiased curves, but for anything more involved than a few hundred points, you'll be better off with matplotlib. Yes, it's that slow... Which means, try the 25000 points demo (Draw4) at your own risk!

This is how I did it (using the AlphaDrawing demo as a template):

Where needed, I replaced

        if dc == None:
            # sets new dc and clears it
            dc = wx.BufferedDC(wx.ClientDC(self.canvas), self._Buffer)
            dc.Clear()

with

        if dc == None:
            # sets new dc and clears it
            pdc = wx.BufferedDC(wx.ClientDC(self.canvas), self._Buffer)
            pdc.Clear()

            try:
                dc = wx.GCDC(pdc)
            except:
                dc = pdc

Now: This probably can be explored a little further:
* replace the current rubberbox with a nice alpha blended one.
* a flag to trigger the antialiased behaviour? Check the number of points?
* only tested this in Windows so far, so any compatibility reports welcome!

Just thought I'd share.

Cheers,
Egor

plot.py (84.8 KB)