Skip to content

Instantly share code, notes, and snippets.

@Merwanski
Created May 13, 2025 20:11
Show Gist options
  • Save Merwanski/633473e6b0279921237bd349cb49ce90 to your computer and use it in GitHub Desktop.
Save Merwanski/633473e6b0279921237bd349cb49ce90 to your computer and use it in GitHub Desktop.
radar py
import matplotlib.pyplot as plt
import numpy as np
# Field labels (6 fields)
labels = [
"Accuracy",
"Responsivity",
"Scalability",
"Cost-effectiveness",
"Simplicity",
"Precision",
]
num_fields = len(labels)
# 4 sample data points, values range from 1 to 5
samples = {
"Vision AI": [4.5, 4, 3, 3, 2, 4],
"UWB": [1, 3, 3, 5, 4, 1],
"ZeroKey": [5, 5, 3, 2, 5, 5],
"Bluetooth*": [2, 3, 4, 4, 3.5, 2],
}
# Create angles for each axis
angles = np.linspace(0, 2 * np.pi, num_fields, endpoint=False).tolist()
angles += angles[:1] # Close the loop
# Setup the plot
fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
# Plot each sample
for label, values in samples.items():
data = values + values[:1] # Close the loop
ax.plot(angles, data, label=label)
ax.fill(angles, data, alpha=0.1)
# Set the field labels
ax.set_xticks(angles[:-1])
ax.set_xticklabels(labels)
# Set the radial limits and grid
ax.set_rlabel_position(30)
ax.set_yticks([1, 2, 3, 4, 5])
ax.set_yticklabels(["1", "2", "3", "4", "5"])
ax.set_ylim(1, 5)
# Add legend and title
plt.legend(loc="upper right", bbox_to_anchor=(1.2, 1.1))
plt.title("RTLS comparison", pad=40)
plt.tight_layout()
# fig.subplots_adjust(top=0.85, bottom=0.15)
plt.savefig("radar_chart.png", dpi=300, bbox_inches="tight")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment