#NEWLINE# def category_scatter( x , y , label_col , data , markers = 'sxo^v' , colors = ( 'blue' , 'green' , 'red' , 'purple' , 'gray' , 'cyan' ) , alpha = 0.7 , markersize = 20.0 , legend_loc = 'best' ) : #NEWLINE# #INDENT# " Scatter plot to plot categories in different colors/markerstyles.\n\n    Parameters\n    ----------\n    x : str or int\n        DataFrame column name of the x-axis values or\n        integer for the numpy ndarray column index.\n    y : str\n        DataFrame column name of the y-axis values or\n        integer for the numpy ndarray column index\n    data : Pandas DataFrame object or NumPy ndarray.\n    markers : str\n        Markers that are cycled through the label category.\n    colors : tuple\n        Colors that are cycled through the label category.\n    alpha : float (default: 0.7)\n        Parameter to control the transparency.\n    markersize : float (default : 20.0)\n        Parameter to control the marker size.\n    legend_loc : str (default: 'best')\n        Location of the plot legend\n        {best, upper left, upper right, lower left, lower right}\n        No legend if legend_loc=False\n\n    Returns\n    ---------\n    fig : matplotlig.pyplot figure object\n\n    " #NEWLINE# fig = plt . figure ( ) #NEWLINE# color_gen = cycle ( colors ) #NEWLINE# marker_gen = cycle ( markers ) #NEWLINE# if isinstance ( data , pd . DataFrame ) : #NEWLINE# #INDENT# for i in ( x , y , label_col ) : #NEWLINE# #INDENT# assert isinstance ( i , str ) #NEWLINE# #UNINDENT# frame = True #NEWLINE# labels = np . unique ( data . loc [ : , label_col ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( data , np . ndarray ) : #NEWLINE# #INDENT# for i in ( x , y , label_col ) : #NEWLINE# #INDENT# assert isinstance ( i , int ) #NEWLINE# #UNINDENT# frame = False #NEWLINE# labels = np . unique ( data [ : , label_col ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'df must be pandas.DataFrame or numpy.ndarray object' ) #NEWLINE# #UNINDENT# #UNINDENT# for lab in labels : #NEWLINE# #INDENT# if frame : #NEWLINE# #INDENT# x_dat = data . loc [ ( ( data . loc [ : , label_col ] == lab ) , x ) ] #NEWLINE# y_dat = data . loc [ ( ( data . loc [ : , label_col ] == lab ) , y ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# x_dat = data [ ( ( markersize [ : , label_col ] == lab ) , x ) ] #NEWLINE# y_dat = data [ ( ( data [ : , label_col ] == lab ) , y ) ] #NEWLINE# #UNINDENT# plt . scatter ( x_dat , y_dat , c = next ( color_gen ) , marker = next ( marker_gen ) , label = lab , alpha = alpha , s = markersize ) #NEWLINE# #UNINDENT# if legend_loc : #NEWLINE# #INDENT# plt . legend ( loc = legend_loc , scatterpoints = 1 ) #NEWLINE# #UNINDENT# return fig