#NEWLINE# def plot( self , * args , **kwargs ) : #NEWLINE# #INDENT# '\n        Plot the given samples from the conditional frequency distribution.\n        For a cumulative plot, specify cumulative=True.\n        (Requires Matplotlib to be installed.)\n\n        :param samples: The samples to plot\n        :type samples: list\n        :param title: The title for the graph\n        :type title: str\n        :param conditions: The conditions to plot (default is all)\n        :type conditions: list\n        ' #NEWLINE# try : #NEWLINE# #INDENT# from matplotlib import pylab #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise ValueError ( 'The plot function requires matplotlib to be installed.See http://matplotlib.org/' ) #NEWLINE# #UNINDENT# cumulative = _get_kwarg ( kwargs , 'cumulative' , False ) #NEWLINE# conditions = _get_kwarg ( kwargs , 'conditions' , sorted ( self . conditions ( ) ) ) #NEWLINE# title = _get_kwarg ( kwargs , 'title' , '' ) #NEWLINE# samples = _get_kwarg ( kwargs , 'samples' , sorted ( set ( ( v for c in conditions for v in self [ c ] ) ) ) ) #NEWLINE# if ( not ( 'linewidth' in kwargs ) ) : #NEWLINE# #INDENT# kwargs [ 'linewidth' ] = 2 #NEWLINE# #UNINDENT# for condition in conditions : #NEWLINE# #INDENT# if cumulative : #NEWLINE# #INDENT# freqs = list ( self [ condition ] . _cumulative_frequencies ( samples ) ) #NEWLINE# ylabel = 'Cumulative Counts' #NEWLINE# legend_loc = 'lower right' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# freqs = [ self [ condition ] [ sample ] for sample in samples ] #NEWLINE# ylabel = 'Counts' #NEWLINE# legend_loc = 'upper right' #NEWLINE# #UNINDENT# kwargs [ 'label' ] = ( '%s' % condition ) #NEWLINE# pylab . plot ( freqs , * args , ** kwargs ) #NEWLINE# #UNINDENT# pylab . legend ( loc = legend_loc ) #NEWLINE# pylab . grid ( True , color = 'silver' ) #NEWLINE# pylab . xticks ( range ( len ( samples ) ) , [ compat . text_type ( s ) for s in samples ] , rotation = 90 ) #NEWLINE# if title : #NEWLINE# #INDENT# pylab . title ( title ) #NEWLINE# #UNINDENT# pylab . xlabel ( 'Samples' ) #NEWLINE# pylab . ylabel ( ylabel ) #NEWLINE# pylab . show ( )