forked from navjotk/error_propagation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotter.py
More file actions
33 lines (28 loc) · 1 KB
/
plotter.py
File metadata and controls
33 lines (28 loc) · 1 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
import matplotlib.pyplot as plt
import tikzplotlib
from util import read_csv
import click
@click.command()
@click.option('--filename', help='File containing results')
@click.option('--basename', help='Base name for output files')
@click.option('--xvar', help='X variable to plot')
@click.option('--yvar', help='Y variable to plot')
@click.option('--xlog/--no-xlog', default=False)
@click.option('--ylog/--no-ylog', default=False)
@click.option('--hline', help='Coordinate for additional horizontal line, if needed', default=None)
def plot(filename, basename, xvar, yvar, xlog, ylog, hline):
results = read_csv(filename)
if xlog:
plt.xscale('log')
if ylog:
plt.yscale('log')
plt.plot(results[xvar], results[yvar])
if hline:
plt.axhline(hline)
plt.xlabel(xvar)
plt.ylabel(yvar)
plt.savefig("%s_%s_%s.pdf" % (basename, yvar, xvar), bbox_inches='tight')
tikzplotlib.save(("%s_%s_%s.tex" % (basename, yvar, xvar)))
plt.clf()
if __name__ == '__main__':
plot()