Issue
I have created a MWE to explain my issue. As seen in the plot below, the curves are moving along the horizontal axis. I need to force the curves to move along the vertical axis, and set the corresponding ticks on the x-axis.
MWE:
import matplotlib.pyplot as plt
import numpy as np
employees = np.arange(0, 12, 76)
sub_one_grades = np.random.normal(0, 1, 76) + 10
sub_two_grades = np.random.normal(0, 1, 76) + 15
sub_three_grades = np.random.normal(0, 1, 76) + 30
# plot
plt.plot(sub_one_grades)
plt.plot(sub_two_grades)
plt.plot(sub_three_grades)
#plt.yticks(employees) #<------REQUIRED, but not working
plt.show()
print()
REQUIRED PLOT:
Solution
import matplotlib.pyplot as plt
import numpy as np
employees = np.arange(0, 76)
sub_one_grades = np.random.normal(0, 1, 76) + 10
sub_two_grades = np.random.normal(0, 1, 76) + 15
sub_three_grades = np.random.normal(0, 1, 76) + 30
#plt.figure(figsize=(12, 30))
plt.plot(sub_one_grades, employees)
plt.plot(sub_two_grades, employees)
plt.plot(sub_three_grades, employees)
#plt.yticks(employees, ['Emp {}'.format(i) for i in employees])
plt.ylabel("Employees")
plt.xlabel("Sub Grades")
plt.show()
you can remove # in the code but the plot would look ugly due to high employee amount
If you uncomment here is what you will get
Answered By - Cem Koçak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.