Issue
I am Building a GUI by Python and want to plot the the daily bonus of employees depends on the user plotting target:
Bob=[100,30,50,90]
Sammy=[10,60,90,200]
Tom=[70,90,90,90]
# input from GUI User is Tom
ploting_target='Tom'
if ploting_target=='Tom':`
plt.plot([0,1,2,3], Tom)
elif ploting_target=='Sammy':
plt.plot([0,1,2,3], Sammy)
plt.plot([0,1,2,3], Tom)
____________________________________________
#expecting
#find_target=list_of_employee.index(ploting_target)
#plt(plot([0,1,2,3], list_of_employee[find_target])
Solution
Your question is unclear. If you have a list of employees, you can probably use Pandas
to organize your data (almost the same as @JohanC suggested with dict
):
# pip install pandas
import pandas as pd
import matplotlib.pyplot as plt
Bob = [100, 30, 50, 90]
Sammy = [10, 60, 90, 200]
Tom = [70, 90, 90, 90]
df = pd.DataFrame({'Bob': Bob, 'Sammy': Sammy, 'Tom': Tom})
df.index = 'Date ' + df.index.astype(str)
Output:
>>> df
Bob Sammy Tom
Day 0 100 10 70
Day 1 30 60 90
Day 2 50 90 90
Day 3 90 200 90
Now you can do df.plot()
:
Or for a specific employee df['Sammy'].plot()
:
Or for a list of employees (but not all) df[['Bob', 'Tom']].plot()
:
Answered By - Corralien
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.