def figure_to_rgb_array(fig, shape=None):
 array = np.frombuffer(_get_buffer(fig, dpi=fig.dpi, format='raw').read(), dtype='uint8')
 if (shape is None):
  (w, h) = fig.canvas.get_width_height()
  shape = (h, w, 4)
 return array.reshape(*shape)

def figure_to_rgb_array ( fig , shape = None ) : array = np . frombuffer ( _get_buffer ( fig , dpi = fig . dpi , format = 'raw' ) . read ( ) , dtype = 'uint8' ) if ( shape is None ) : ( w , h ) = fig . canvas . get_width_height ( ) shape = ( h , w , 4 ) return array . reshape ( * shape )
converts figure to a numpy array parameters fig : matplotlib .