Run a demonstration
()
| 48 | |
| 49 | |
| 50 | def run_demo(): |
| 51 | """ |
| 52 | Run a demonstration |
| 53 | """ |
| 54 | module_dir = dirname(dirname(os.path.realpath(__file__))) |
| 55 | demo_file = os.path.join(module_dir, 'examples/data/exp.txt') |
| 56 | |
| 57 | if not os.path.isfile(demo_file): |
| 58 | sys.stderr.write("demo input file not found!\n") |
| 59 | sys.stderr.write("run the downloaddata.sh script in the example first\n") |
| 60 | sys.exit(1) |
| 61 | |
| 62 | # plotting a histogram |
| 63 | print("plotting a basic histogram") |
| 64 | print("plot_hist('%s')" % demo_file) |
| 65 | print("hist -f %s" % demo_file) |
| 66 | print("cat %s | hist" % demo_file) |
| 67 | plot_hist(demo_file) |
| 68 | print("*" * 80) |
| 69 | |
| 70 | # with colours |
| 71 | print("histogram with colours") |
| 72 | print("plot_hist('%s', colour='blue')" % demo_file) |
| 73 | print("hist -f %s -c blue" % demo_file) |
| 74 | plot_hist(demo_file, colour='blue') |
| 75 | print("*" * 80) |
| 76 | |
| 77 | # changing the shape of the point |
| 78 | print("changing the shape of the bars") |
| 79 | print("plot_hist('%s', pch='.')" % demo_file) |
| 80 | print("hist -f %s -p ." % demo_file) |
| 81 | plot_hist(demo_file, pch='.') |
| 82 | print("*" * 80) |
| 83 | |
| 84 | # changing the size of the plot |
| 85 | print("changing the size of the plot") |
| 86 | print("plot_hist('%s', height=35.0, bincount=40)" % demo_file) |
| 87 | print("hist -f %s -s 35.0 -b 40" % demo_file) |
| 88 | plot_hist(demo_file, height=35.0, bincount=40) |
| 89 | |
| 90 | |
| 91 | def plot_hist(f, height=20.0, bincount=None, binwidth=None, pch="o", colour="default", title="", xlab=None, showSummary=False, regular=False): |