Created
September 11, 2019 08:03
-
-
Save jamescalam/ddaeffd71e4c64b2a2b3a9279b4b7ede to your computer and use it in GitHub Desktop.
Example math behind creating a radar plot using continuous data split in several categories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def xy(a, b, c, d, n): | |
v = [a, b, c, d] | |
r = (np.average(v)-np.min(v))/(np.max(v)-np.min(v)) | |
x = r*np.cos((np.pi/3)*n) | |
y = r*np.sin((np.pi/3)*n) | |
return x, y | |
inputs = [[2056301.8, 8177980, 2710877.4, 1201452.32], | |
[1450601.21, 3114586.72, 1034670, 801342.4], | |
[14, 34, 12, 2], [0.09, 0.34, 0.16, 0.22], | |
[451.26, 1451, 240.8, 65.51], | |
[5, 9, 4, 6]] | |
x = [] | |
y = [] | |
for n, items in enumerate(inputs): | |
x_, y_ = xy(items[0], items[1], items[2], items[3], n) | |
x.append(x_) | |
y.append(y_) | |
plt.figure(figsize=(8, 8)) | |
plt.scatter(x, y, color='k') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment