RuntimeError: failed to gain raw access

Using mpl 0.99.1 and sometimes get the following exception.

Traceback (most recent call last):
   File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\", line 14640, in <lambda>
     lambda event: event.callable(*event.args, ** )
   File "C:\dev\TwcbBranchesV32\Program\", line 385, in RefreshAllGraphs
     self.RefreshCountryValue(self.countryValueP, self.countryValue)
   File "C:\dev\TwcbBranchesV32\Program\", line 417, in RefreshCountryValue
     self.DoStatsParetoAlt(sql, panel, axes, _('Value - in home currency'), _('Purchase value in % of cumulated purchase value'), avg=True)
   File "C:\dev\TwcbBranchesV32\Program\", line 992, in DoStatsParetoAlt
   File "C:\Python26\lib\site-packages\matplotlib\backends\", line 61, in draw
     self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
   File "C:\Python26\lib\site-packages\matplotlib\backends\", line 229, in _py_WX28_convert_agg_to_wx_bitmap
     agg.buffer_rgba(0, 0))
   File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\", line 908, in BitmapFromBufferRGBA
     return _gdi_._BitmapFromBufferRGBA(width, height, dataBuffer)
RuntimeError: Failed to gain raw access to bitmap data.

I thought/guessed it had to do with not having resized the canvas correctly, but I am not sure and the following code is run whenever I resize the parent of the canvas.

     def _SetSize( self ):
         pixels = tuple( self.parent.GetClientSize() )
         self.SetSize( pixels )
         self.canvas.SetSize( pixels )
         self.figure.set_size_inches( float( pixels[0] )/self.figure.get_dpi(),
                                      float( pixels[1] )/self.figure.get_dpi() )

What could the cause of this error be?