code: def fig2bmp(figure, width, height, dpi, zoom):
      
  
      dpi *= float(zoom)
  
      figure.set_figwidth(width / dpi)
      figure.set_figheight(height / dpi)
      figure.subplots_adjust()
  
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
  
      try:
          # The padding is too small for small sizes. This fixes it.
          figure.tight_layout(pad=1.0/zoom)
      except ValueError:
          pass
  
      figure.set_canvas(FigureCanvas(figure))
      png_stream = StringIO()
  
      figure.savefig(png_stream, format='png', dpi=(dpi))
  
      png_stream.seek(0)
      img = wx.ImageFromStream(png_stream, type=wx.BITMAP_TYPE_PNG)
  
      return wx.BitmapFromImage(img)
docs: Returns wx.Bitmap from matplotlib chart
  
      Parameters
      ----------
      fig: Object
      \tMatplotlib figure
      width: Integer
      \tImage width in pixels
      height: Integer
      \tImage height in pixels
      dpi = Float
      \tDC resolution