Home > database >  Plotting a Radar drawing with matplotlib not working correctly
Plotting a Radar drawing with matplotlib not working correctly

Time:04-20

I found this resource:

enter image description here

What am I missing here?

CodePudding user response:

I don't think the original source code is correct. This produces the desired output:

enter image description here

import numpy as np
import matplotlib.pyplot as plt

categories = ['Joy', 'Fear', 'Anger', 'Sadness', 'Disgust', 'Shame','Guilt']

q1 = [4, 4, 5, 4, 3, 7, 10]
q2 = [5, 5, 4, 5, 2, 9, 2]
q3 = [3, 4, 5, 3, 5, 10, 2]
q4 = [3, 4, 5, 3, 5, 8, 8]

label_loc = np.linspace(start=0, stop=2*np.pi, num=len(q1) 1)

plt.figure(figsize=(8, 8))
plt.subplot(polar=True)
for q in [q1, q2, q3, q4]:
    plt.plot(label_loc, np.r_[q, q[0]], label='q 1')
plt.title('Answer to Question 1 - Emotion Analysis', size=20)
lines, labels = plt.thetagrids(np.degrees(label_loc), labels=categories)
plt.legend()
plt.show()
  • Related