From e032b99a9155e0eec992e01e87798348c9cd302d Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Sun, 29 Jan 2023 19:06:35 -0700 Subject: [PATCH] Test sample polar plot --- polar-plot | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/polar-plot b/polar-plot index 787049b..8465d72 100755 --- a/polar-plot +++ b/polar-plot @@ -28,15 +28,19 @@ # ./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 import pandas as pd import re +import scipy import seaborn as sns import sys +from pandas.plotting import scatter_matrix + locale.setlocale(locale.LC_ALL, "en_US.utf8") plt.rcParams["axes.formatter.use_locale"] = True @@ -61,7 +65,7 @@ def load_samples(): with open(datafile) as f: firstline = f.readline().rstrip() - if firstline == "1, -38.93": + if firstline == "1, 38.93": print("Test data from sample.csv") df = pd.read_csv( datafile, skiprows=0, usecols=[0, 1], names=("Azimuth", "Energy") @@ -75,7 +79,7 @@ def load_samples(): print("Unknown file type.") exit() - return(df) + return df def print_table(df): @@ -84,8 +88,7 @@ def print_table(df): print(df) -def display_plot(): - # (Empty) Plot here +def display_plot(df): sns.set_theme() fig = plt.figure(figsize=(8, 8), facecolor="xkcd:off white") ax = fig.add_subplot(111, projection="polar") @@ -102,9 +105,33 @@ def display_plot(): ax.set_rticks([90, 60, 30, 0]) ax.set_rgrids([90, 60, 30, 0], ["", "30$^\circ$", "60$^\circ$", ""], angle=22.5) ax.grid(True) - ax.bar(0, 90).remove() - ax.set_rmax(90.0) - ax.set_ylim(0.0, 90.0) + + ax.bar(1 / 60, 38.93, width=0.25) + ax.bar(15 / 60, 38.31, width=0.25) + ax.bar(30 / 60, 37.77, width=0.25) + ax.bar(45 / 60, 37.33, width=0.25) + ax.bar(60 / 60, 38.54, width=0.25) + ax.bar(75 / 60, 38.81, width=0.25) + ax.bar(90 / 60, 37.55, width=0.25) + ax.bar(105 / 60, 29.18, width=0.25) + ax.bar(120 / 60, 29.32, width=0.25) + ax.bar(135 / 60, 37.00, width=0.25) + ax.bar(150 / 60, 36.48, width=0.25) + ax.bar(165 / 60, 32.46, width=0.25) + ax.bar(180 / 60, 34.92, width=0.25) + ax.bar(195 / 60, 38.65, width=0.25) + ax.bar(210 / 60, 39.07, width=0.25) + ax.bar(225 / 60, 39.50, width=0.25) + ax.bar(240 / 60, 39.42, width=0.25) + ax.bar(255 / 60, 37.33, width=0.25) + ax.bar(270 / 60, 38.96, width=0.25) + ax.bar(285 / 60, 38.14, width=0.25) + ax.bar(300 / 60, 36.32, width=0.25) + ax.bar(315 / 60, 35.26, width=0.25) + ax.bar(330 / 60, 39.14, width=0.25) + ax.bar(345 / 60, 39.60, width=0.25) + + ax.set_ylim(0.0, 40.0) plt.tight_layout() plt.show() @@ -112,7 +139,7 @@ def display_plot(): def main(): df = load_samples() print_table(df) - display_plot() + display_plot(df) if __name__ == "__main__":