Issue
I found this resource:
And I am trying to create my own version where I will analyze emotions for a free text survey. Instead of 5 categories, I will have 7 emotions:
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))
plt.figure(figsize=(8, 8))
plt.subplot(polar=True)
plt.plot(label_loc, q1, label='q 1')
plt.plot(label_loc, q2, label='q 2')
plt.plot(label_loc, q3, label='q 3')
plt.plot(label_loc, q4, label='q 4')
plt.title('Answer to Question 1 - Emotion Analysis', size=20)
lines, labels = plt.thetagrids(np.degrees(label_loc), labels=categories)
plt.legend()
plt.show()
However the Joy and Guilt emotions are overlapping in the drawing.
What am I missing here?
Solution
I don't think the original source code is correct. This produces the desired output:
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()
Answered By - Paul Brodersen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.