Split out functions, use argparse
parent
3edfef26f2
commit
e8ab01d886
34
polar-plot
34
polar-plot
|
@ -28,6 +28,7 @@
|
|||
# ./polar-plot data/sample.csv
|
||||
# ./polar-plot data/rtl_power-sample.csv
|
||||
|
||||
import argparse
|
||||
import locale
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
@ -39,9 +40,23 @@ import sys
|
|||
locale.setlocale(locale.LC_ALL, "en_US.utf8")
|
||||
plt.rcParams["axes.formatter.use_locale"] = True
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Determine what type of file to load to dataframe
|
||||
datafile = sys.argv[1]
|
||||
|
||||
def load_samples():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Radio Interference Polar Plotter.",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
)
|
||||
parser.add_argument(
|
||||
"infile",
|
||||
nargs="?",
|
||||
type=argparse.FileType("r"),
|
||||
default=sys.stdin,
|
||||
help="filename, default stdin",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
datafile = args.infile.name
|
||||
|
||||
with open(datafile) as f:
|
||||
firstline = f.readline().rstrip()
|
||||
|
@ -64,11 +79,13 @@ if __name__ == "__main__":
|
|||
with pd.option_context("display.max_rows", None, "display.max_columns", None):
|
||||
print(df)
|
||||
|
||||
|
||||
def display_plot():
|
||||
# (Empty) Plot here
|
||||
sns.set_theme()
|
||||
fig = plt.figure(figsize=(8, 8), facecolor="xkcd:off white")
|
||||
ax = fig.add_subplot(111, projection="polar")
|
||||
ax.set_facecolor('xkcd:powder blue')
|
||||
ax.set_facecolor("xkcd:powder blue")
|
||||
|
||||
ax.set_title(
|
||||
"Radio Interference Polar Plot".format("seaborn"),
|
||||
|
@ -86,3 +103,12 @@ if __name__ == "__main__":
|
|||
ax.set_ylim(0.0, 90.0)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
|
||||
|
||||
def main():
|
||||
load_samples()
|
||||
display_plot()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue