PEATSA/Core/Utilities.py
def CreateBarChart(matrix, column, outputFile, xaxis=None, **options):

	'''Creates a bar chart out of the specified data
	
	Parameters:
		Matrix: A Matrix.Matrix instance containing the data to create the chart from
		column: The name of the column containing the value (yAxis) data
		outputFile: The file to write the chart to
		xaxis: The name of the column containing the xaxis values.
			If None the row index of each y value is used.
	
	Keyword Args (All currently required):
		title
		xticIncrement
		xlabel
		ylabel
		'''

	string = '''set datafile separator ','
set xlabel '%s'
#set xtics nomirror %d
set ylabel '%s'
set term png size 1280,800
set output '%s'
set boxwidth 0.5 relative
set style fill solid 0.8
plot '%s' u %d:%d with boxes t '%s' '''
		
	stream = open('.matrix.csv', 'w+')
	stream.write(matrix.csvRepresentation())	
	stream.close()

	#Have to add 1 since gnuplot indexes from 1 while pythong indexes from 0
	columnIndex = matrix.indexOfColumnWithHeader(column) + 1

	#If no xColumn is specified set it to 0 i.e. row index
	if xaxis == None:
		xaxisIndex = 0
	else:
		xaxisIndex = matrix.indexOfColumnWithHeader(xaxis) + 1
		
	string = string % (options['xlabel'], int(options['xticIncrement']), options['ylabel'], 
				outputFile, ".matrix.csv", xaxisIndex, int(columnIndex), options['title']) 		
	stream = open('.temp', 'w+')
	stream.write(string)
	stream.close()

	try:
		if options.has_key('gnuplotPath'):
			gnuplotPath = options['gnuplotPath']
		elif Environment.appConfiguration is not None:
			gnuplotPath = Environment.appConfiguration.get('PATHS', 'gnuplot')
		else:
			raise BaseException
	except:
		gnuplotPath = '/usr/local/bin'
			
	process = subprocess.Popen("%s/gnuplot .temp" % gnuplotPath, shell=True)
	process.wait()
	
	#print 'Done creating graph'
	
	os.remove('.temp')
	os.remove('.matrix.csv')
	
	return process.returncode
Creates a bar chart out of the specified data
	
	Parameters:
		Matrix: A Matrix.Matrix instance containing the data to create the chart from
		column: The name of the column containing the value (yAxis) data
		outputFile: The file to write the chart to
		xaxis: The name of the column containing the xaxis values.
			If None the row index of each y value is used.
	
	Keyword Args (All currently required):
		title
		xticIncrement
		xlabel
		ylabel
		
Creates a bar chart out of the specified data
Creates a bar chart out of the specified data
def CreateBarChart(matrix, column, outputFile, xaxis=None, **options):
	string = '''set datafile separator ','
set xlabel '%s'
#set xtics nomirror %d
set ylabel '%s'
set term png size 1280,800
set output '%s'
set boxwidth 0.5 relative
set style fill solid 0.8
plot '%s' u %d:%d with boxes t '%s' '''
	stream = open('.matrix.csv', 'w+')
	stream.write(matrix.csvRepresentation())	
	stream.close()
	columnIndex = matrix.indexOfColumnWithHeader(column) + 1
	if xaxis == None:
		xaxisIndex = 0
	else:
		xaxisIndex = matrix.indexOfColumnWithHeader(xaxis) + 1
	string = string % (options['xlabel'], int(options['xticIncrement']), options['ylabel'], 
				outputFile, ".matrix.csv", xaxisIndex, int(columnIndex), options['title']) 		
	stream = open('.temp', 'w+')
	stream.write(string)
	stream.close()
	try:
		if options.has_key('gnuplotPath'):
			gnuplotPath = options['gnuplotPath']
		elif Environment.appConfiguration is not None:
			gnuplotPath = Environment.appConfiguration.get('PATHS', 'gnuplot')
		else:
			raise BaseException
	except:
		gnuplotPath = '/usr/local/bin'
	process = subprocess.Popen("%s/gnuplot .temp" % gnuplotPath, shell=True)
	process.wait()
	os.remove('.temp')
	os.remove('.matrix.csv')
	return process.returncode
def CreateBarChart ( matrix , column , outputFile , xaxis = None , ** options ) : string = '''set datafile separator ','
set xlabel '%s'
#set xtics nomirror %d
set ylabel '%s'
set term png size 1280,800
set output '%s'
set boxwidth 0.5 relative
set style fill solid 0.8
plot '%s' u %d:%d with boxes t '%s' ''' stream = open ( '.matrix.csv' , 'w+' ) stream . write ( matrix . csvRepresentation ( ) ) stream . close ( ) columnIndex = matrix . indexOfColumnWithHeader ( column ) + 1 if xaxis == None : xaxisIndex = 0 else : xaxisIndex = matrix . indexOfColumnWithHeader ( xaxis ) + 1 string = string % ( options [ 'xlabel' ] , int ( options [ 'xticIncrement' ] ) , options [ 'ylabel' ] , outputFile , ".matrix.csv" , xaxisIndex , int ( columnIndex ) , options [ 'title' ] ) stream = open ( '.temp' , 'w+' ) stream . write ( string ) stream . close ( ) try : if options . has_key ( 'gnuplotPath' ) : gnuplotPath = options [ 'gnuplotPath' ] elif Environment . appConfiguration is not None : gnuplotPath = Environment . appConfiguration . get ( 'PATHS' , 'gnuplot' ) else : raise BaseException except : gnuplotPath = '/usr/local/bin' process = subprocess . Popen ( "%s/gnuplot .temp" % gnuplotPath , shell = True ) process . wait ( ) os . remove ( '.temp' ) os . remove ( '.matrix.csv' ) return process . returncode
Creates a bar chart out of the specified data
Creates a bar chart out of the specified data
'''Creates a bar chart out of the specified data
	
	Parameters:
		Matrix: A Matrix.Matrix instance containing the data to create the chart from
		column: The name of the column containing the value (yAxis) data
		outputFile: The file to write the chart to
		xaxis: The name of the column containing the xaxis values.
			If None the row index of each y value is used.
	
	Keyword Args (All currently required):
		title
		xticIncrement
		xlabel
		ylabel
		''' #Have to add 1 since gnuplot indexes from 1 while pythong indexes from 0 #If no xColumn is specified set it to 0 i.e. row index #print 'Done creating graph'
matrix
column
The name of the column containing the value (yAxis) data
The name of the column containing the value ( yAxis ) data
outputFile
The file to write the chart to
The file to write the chart to
xaxis
The name of the column containing the xaxis values.
If None the row index of each y value is used.
The name of the column containing the xaxis values . If None the row index of each y value is used .
Matrix
A Matrix.Matrix instance containing the data to create the chart from
A Matrix . Matrix instance containing the data to create the chart from