-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot.py
More file actions
48 lines (39 loc) · 1.16 KB
/
Copy pathplot.py
File metadata and controls
48 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Script for plotting data.
On error bars:
https://problemsolvingwithpython.com/06-Plotting-with-Matplotlib/06.07-Error-Bars/
"""
import numpy as np
import matplotlib.pyplot as plt
import argparse
import pandas as pd
if __name__ == '__main__':
# CLI
parser = argparse.ArgumentParser('plotting statst')
parser.add_argument('read_path')
parser.add_argument('write_path')
parser.add_argument('--x_label', required=True)
parser.add_argument('--y_label', required=True)
parser.add_argument('--title', required=True)
args = parser.parse_args()
# Load data
data = pd.read_csv(args.read_path)
# Plotting elements
labels = data['n']
x_pos = np.arange(len(labels))
errs = data['std_error']
means = data['mean']
# Plotting
fig, ax = plt.subplots()
ax.bar(x_pos, means,
yerr=errs,
align='center',
alpha=0.5,
ecolor='black',
capsize=10)
ax.set_xlabel(args.x_label)
ax.set_xticks(x_pos)
ax.set_xticklabels(labels)
ax.set_ylabel(args.y_label)
ax.set_title(args.title)
ax.yaxis.grid(True)
fig.savefig(args.write_path, bbox_inches='tight')