Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have this code: df_pre_2003.groupby([\'year\'])[\'nAllNeonic\'].sum().plot(col

ID: 3744253 • Letter: I

Question

I have this code:

df_pre_2003.groupby(['year'])['nAllNeonic'].sum().plot(color='red')
plt.title("Neonic usage prior to 2003")

It currently produces a simple line graph. That looks like this

I would like to have a slider implement to it either through plotly or matplotlib. I tried but, was having trouble. For the data here is some sample data. This is just a small sample but I hope it's enough to give a general sense of it. Thank you!


StateName Year nAllNeonic Alabama 1997 6701.8 Alabama 1993 635.4 Alabama 2001 1441.6 Alabama 1994 6651.4 Alabama 2011 4325.2 Alabama 2013 901.8 Alaska 2016 568.3 Alaska 2017 4550.7 Alaska 1993 6804.1 df_pre_2003.groupby ( year')I'nAllNeonic'].sum().plot(color-'red') plt.title("Neonic usage prior to 2003") Text(0.5,1, Neonic usage prior to 2003') Neonic usage prior to 2003 175000 150000 125000 100000 75000 50000 25000 1992 1994 1996 1998 2000 2002 year

Explanation / Answer

# code take input from cmd line and show graph(use python language)

import matplotlib.pyplot as plt

n =input("What is your length of data table ")#in integer like 10,5

print("Enter your Year and nAllNeonic for whole table")

a=[1997,1994,1993]

b=[6701.4,6651.4,6874.5]

for i in range(0,n):

a.insert( i, input())

b.insert( i, input())

plt.plot(a, b,'r')

plt.xlabel('Year')

plt.ylabel('nAllNeonic Usage')