1
0
Fork 0

Test sample polar plot

main
Jeff Moe 2023-01-29 19:06:35 -07:00
parent 3636b0cd96
commit e032b99a91
1 changed files with 35 additions and 8 deletions

View File

@ -28,15 +28,19 @@
# ./polar-plot data/sample.csv # ./polar-plot data/sample.csv
# ./polar-plot data/rtl_power-sample.csv # ./polar-plot data/rtl_power-sample.csv
import argparse import argparse
import locale import locale
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import re import re
import scipy
import seaborn as sns import seaborn as sns
import sys import sys
from pandas.plotting import scatter_matrix
locale.setlocale(locale.LC_ALL, "en_US.utf8") locale.setlocale(locale.LC_ALL, "en_US.utf8")
plt.rcParams["axes.formatter.use_locale"] = True plt.rcParams["axes.formatter.use_locale"] = True
@ -61,7 +65,7 @@ def load_samples():
with open(datafile) as f: with open(datafile) as f:
firstline = f.readline().rstrip() firstline = f.readline().rstrip()
if firstline == "1, -38.93": if firstline == "1, 38.93":
print("Test data from sample.csv") print("Test data from sample.csv")
df = pd.read_csv( df = pd.read_csv(
datafile, skiprows=0, usecols=[0, 1], names=("Azimuth", "Energy") datafile, skiprows=0, usecols=[0, 1], names=("Azimuth", "Energy")
@ -75,7 +79,7 @@ def load_samples():
print("Unknown file type.") print("Unknown file type.")
exit() exit()
return(df) return df
def print_table(df): def print_table(df):
@ -84,8 +88,7 @@ def print_table(df):
print(df) print(df)
def display_plot(): def display_plot(df):
# (Empty) Plot here
sns.set_theme() sns.set_theme()
fig = plt.figure(figsize=(8, 8), facecolor="xkcd:off white") fig = plt.figure(figsize=(8, 8), facecolor="xkcd:off white")
ax = fig.add_subplot(111, projection="polar") ax = fig.add_subplot(111, projection="polar")
@ -102,9 +105,33 @@ def display_plot():
ax.set_rticks([90, 60, 30, 0]) ax.set_rticks([90, 60, 30, 0])
ax.set_rgrids([90, 60, 30, 0], ["", "30$^\circ$", "60$^\circ$", ""], angle=22.5) ax.set_rgrids([90, 60, 30, 0], ["", "30$^\circ$", "60$^\circ$", ""], angle=22.5)
ax.grid(True) ax.grid(True)
ax.bar(0, 90).remove()
ax.set_rmax(90.0) ax.bar(1 / 60, 38.93, width=0.25)
ax.set_ylim(0.0, 90.0) 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.tight_layout()
plt.show() plt.show()
@ -112,7 +139,7 @@ def display_plot():
def main(): def main():
df = load_samples() df = load_samples()
print_table(df) print_table(df)
display_plot() display_plot(df)
if __name__ == "__main__": if __name__ == "__main__":