original_docstring: 
      @brief Convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it
      @param fig a matplotlib figure
      @return a numpy 3D array of RGBA values
      
docstring: @brief Convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it
  @param fig a matplotlib figure
  @return a numpy 3D array of RGBA values
docstring_tokens: @brief Convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it @param fig a matplotlib figure @return a numpy 3D array of RGBA values
code: def fig2data ( fig ):
      """
      @brief Convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it
      @param fig a matplotlib figure
      @return a numpy 3D array of RGBA values
      """
      # draw the renderer
      fig.canvas.draw ( )
  
      # Get the RGBA buffer from the figure
      w,h = fig.canvas.get_width_height()
      buf = np.fromstring( fig.canvas.tostring_argb(), dtype=np.uint8 )
      buf.shape = ( w, h,4 )
  
      # canvas.tostring_argb give pixmap in ARGB mode. Roll the ALPHA channel to have it in RGBA mode
      buf = np.roll ( buf, 3, axis = 2 )
      return buf
code_tokens: def fig2data ( fig ) : fig . canvas . draw ( ) w , h = fig . canvas . get_width_height ( ) buf = np . fromstring ( fig . canvas . tostring_argb ( ) , dtype = np . uint8 ) buf . shape = ( w , h , 4 ) buf = np . roll ( buf , 3 , axis = 2 ) return buf
short_docstring: @brief Convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it
  @param fig a matplotlib figure
  @return a numpy 3D array of RGBA values
short_docstring_tokens: @brief Convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it @param fig a matplotlib figure @return a numpy 3D array of RGBA values
comment: """
      @brief Convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it
      @param fig a matplotlib figure
      @return a numpy 3D array of RGBA values
      """$SEP$# draw the renderer$SEP$# Get the RGBA buffer from the figure$SEP$# canvas.tostring_argb give pixmap in ARGB mode. Roll the ALPHA channel to have it in RGBA mode