plotter.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import argparse
00004 import bwi_tools.graph as graph
00005 import bwi_tools.filesystem as fs
00006 import json
00007 import matplotlib.pyplot as plt; plt.rcdefaults()
00008 
00009 parser = argparse.ArgumentParser()
00010 parser.add_argument("data", help="The directory containing csv files or a single csv file.", type=str)
00011 parser.add_argument("output", help="Column name in csv to plot.", type=str)
00012 parser.add_argument("--plot-type", help="Plot type. One of ['line', 'bar', '3d'].", type=str)
00013 parser.add_argument("--filter", help="Comma separated primary grouping filter. Defaults to 'name' if available",
00014                     type=str)
00015 parser.add_argument("--secondary-filter", help="Comma separated secondary grouping filter.", type=str)
00016 parser.add_argument("--name-mappings", help="JSON string with mapping from column name to printed name.", type=str)
00017 parser.add_argument("--attempt_auto_mapping", help="Attempt to perform automatic cleanup of CSV column name.", 
00018                     action='store_true')
00019 
00020 args = parser.parse_args()
00021 
00022 if not args.plot_type:
00023     args.plot_type = 'bar'
00024 
00025 name_mappings = None
00026 if args.name_mappings is not None:
00027     name_mappings = json.loads(args.name_mappings)
00028 
00029 fig, ax, rects, means= \
00030         graph.draw_from_data_frame(fs.expand_path_to_filelist(args.data), 
00031                                    args.output, args.plot_type, args.filter, args.secondary_filter, 
00032                                    args.attempt_auto_mapping, name_mappings)
00033 
00034 
00035 fig = plt.gcf()
00036 fig.set_size_inches(5,4)
00037 pad_inches = 0.1
00038 if args.plot_type == "3d":
00039     azim = raw_input("Enter Azimuth [Hit enter to default to -70]: ")
00040     if azim is None or azim == "":
00041         azim = -70
00042     elev = raw_input("Enter Elevation [Hit enter to default to 25]: ")
00043     if elev is None or elev == "":
00044         elev = 25
00045     ax.view_init(elev=float(elev), azim=float(azim))
00046 
00047 plt.savefig('out.png',bbox_inches='tight',pad_inches=pad_inches,dpi=100)
00048 plt.show()


bwi_tools
Author(s): Piyush Khandelwal
autogenerated on Fri Aug 28 2015 10:14:30