python - Type error: Plotting an array including tuples -


i'm gonna solve , plot nonlinear equation matplotlib, there error saying:

typeerror: zip argument #1 must support iteration

can me fix it?...

import numpy np import matplotlib.pyplot plt scipy.optimize import fsolve  r = np.arange(-100, 100, step=0.01, dtype=float)  def equation(p,r0):     x = p     r = r0     return (r * x + np.power(x,3)- np.power(x,5))  temp = []  in r:     x = fsolve(equation, 0, args=(i,))     temp.extend((i,x))  my_array = np.array(temp)  #print(my_array) x, y = zip(*my_array) plt.plot(x,y) 

as @julien said, must use append instead of extend. furthermore, guess can't see result because there no plt.show() in snippet. need add right after plt.plot(x,y). then, output be:

enter image description here

you better change initial guess else because 0 answer equation r. example, here result 2:

enter image description here


Comments