from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import math
from scipy.integrate import odeint
from scipy.fftpack import fft, ifft
def pend(y, t, a, b, ohm):
theta, omega, phi = y
dydt = [omega, -b*omega-np.sin(theta)-a*np.cos(phi), ohm]
return dydt
b = 1.0/2.0 #beta
ohm = 2.0/3.0 #capital Omega
period = 2.0*math.pi/ohm #driving period
t0 = 0.0 #initial time
t = np.linspace(t0,t0+period*10**3,10**3+1) #time for Poincare map
theta0 = 0.75
omega0 = 1.6
phi0 = 0.8
y0 = [theta0,omega0,phi0] #initial conditions
N = 100 #number of transient points to delete
a_array = np.linspace(0,1.15,50) #varying parameter of a values
for a in a_array:
sol = odeint(pend,y0,t,args=(a,b,ohm)) #numerical integration of differential equation
sol = sol[N:10**3-N] #removing transients
w = sol[:,1] #frequency
A = np.full(len(w),a) #array of a-values
plt.plot(A, w)
plt.draw()
현재 분기 다이어그램을 구성하려고합니다. 우리가 사용하는 방정식 시스템에서, a는 제어 매개 변수이며, x의 0과 1.15 사이의 값과 a의 특정 값에 대한 값의 배열 (w라고 함)을 나타냅니다. 나는 이렇게 for 루프 내에서 물건을 그리는 법을 정말로 모르겠다. 서브 플로트가 가장 좋은 방법이라고 들었지만 구현에 익숙하지 않아 도움이 될 수 있습니다. 감사!동일한 그래프에 여러 개의 하위 그림 그리기
지금 당신의 코드를 실행합니다. 시간이 좀 걸릴. 그 동안 보통 plt.draw() 또는 plt.show()를 루프 외부로 이동합니다. –