From f92ff795020298beff15ddf8ce7e35a4f13c85ed Mon Sep 17 00:00:00 2001 From: Anton Nekrutenko Date: Tue, 11 Mar 2008 12:45:55 +0000 Subject: [PATCH] Changes to bar chart tool --- tools/plotting/bar_chart.py | 17 ++++++++--------- tools/plotting/bar_chart.xml | 4 +++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/plotting/bar_chart.py b/tools/plotting/bar_chart.py index 855e9e25373..b33dc37b233 100644 --- a/tools/plotting/bar_chart.py +++ b/tools/plotting/bar_chart.py @@ -12,7 +12,7 @@ a generic histogram builder based on gnuplot backend ylabel - y axis label yrange_max - minimal value at the y axis (integer) yrange_max - maximal value at the y_axis (integer) - to set yrange to auto assign 0 to yrange_mmin and yrange_max + to set yrange to autoscaling assign 0 to yrange_mmin and yrange_max graph_file - file to write histogram image to pdf_size - as X,Y pair in inches (e.g., 11,8 or 8,11 etc.) @@ -65,7 +65,7 @@ def main(tmpFileName): try: fields = line.split( '\t' ) for col in col_list: - row.append( str( float( fields[int(col)-1] ) ) ) + row.append( str( float( fields[int( col )-1] ) ) ) except: valid = False @@ -95,17 +95,15 @@ def main(tmpFileName): #set the first column if xtic > 0: g_plot_command = "'%s' using 1:xticlabels(%s) ti 'Column %s', " % ( tmpFileName, str( len( row ) ), col_list[0] ) - #g_plot_command = "'%s' using 1:xticlabels(%s), " % ( tmpFileName, str( len( row ) ) ) else: g_plot_command = "'%s' using 1, " % ( tmpFileName ) #set subsequent columns for i in range(1,len(col_list)): - g_plot_command += "'%s' using %s t 'Column %s', " % ( tmpFileName, str(i+1), col_list[i] ) - #g_plot_command += "'%s' using %s, " % ( tmpFileName, str(i+1) ) + g_plot_command += "'%s' using %s t 'Column %s', " % ( tmpFileName, str( i+1 ), col_list[i] ) - g_plot_command = g_plot_command.rstrip(', ') + g_plot_command = g_plot_command.rstrip( ', ' ) yrange = 'set yrange [' + ymin + ":" + ymax + ']' @@ -131,14 +129,15 @@ def main(tmpFileName): except: stop_err("Gnuplot error: Data cannot be plotted") else: - sys.stderr.write('Columns %s of your dataset do not contain valid numeric data' %sys.argv[3] ) + sys.stderr.write('Column(s) %s of your dataset do not contain valid numeric data' %sys.argv[3] ) if skipped_lines_count > 0: - sys.stderr.write('You dataset contains %d invalid lines starting with line#%d\n' % ( skipped_lines_count, skipped_lines_index[0] ) ) + sys.stdout.write('\nWARNING. You dataset contain(s) %d invalid lines starting with line #%d. These lines were skipped while building the graph.\n' % ( skipped_lines_count, skipped_lines_index[0]+1 ) ) if __name__ == "__main__": + # The tempfile initialization is here because while inside the main() it seems to create a condition + # when the file is removed before gnuplot has a chance of accessing it gp_data_file = tempfile.NamedTemporaryFile('w') - #gp_f, gp_data_file = tempfile.mkstemp(suffix="gp", text=True) main(gp_data_file.name) diff --git a/tools/plotting/bar_chart.xml b/tools/plotting/bar_chart.xml index 810d373ca3b..17e1f03aa4f 100644 --- a/tools/plotting/bar_chart.xml +++ b/tools/plotting/bar_chart.xml @@ -45,7 +45,9 @@ This tool builds a bar chart on one or more columns. Suppose you have dataset li Graphing columns 2 and 3 while using column 1 for X Tick Labels will produce the following plot: -.. image:: ../static/images/bar_chart.png +.. image:: ../static/images/bar_chart.png + :height: 324 + :width: 540