약간의 문제가 있습니다. 나는 가능성을 위해 웨이브 함수를 그리는 프로그램을 가지고 있는데, 플롯 (pylab 사용)에서 '-'옵션을 사용할 때 괜찮아 보인다. http://img41.imageshack.us/img41/8798/59138635.pngmatplotlib : 마커를 사용할 때 추한 플롯
'o'를 사용하면 다음을 얻을 수있다. 원 더 간격을 만들 수있는 간단한 방법이 있나요
\, 또는 코드의 세부 사항에 따라 달라집니다 않습니다 http://img16.imageshack.us/img16/3741/22378006.png
당신은 추한 보이는 것을 알?
코드는 다음과 같습니다 그것은 추한 모습
from math import *
from scipy.special import *
from pylab import *
from scipy.linalg import *
firebrick=(178./255.,34./255.,34./255.)
indianred=(176./255.,23./255.,31./255.)
steelblue=(70./255.,130./255.,180./255.)
slategray1=(198./255.,226./255.,255./255.)
slategray4=(108./255.,123./255.,139./255.)
lavender=(230./255.,230./255.,230./255.)
cobalt=(61./255.,89./255.,171./255.)
midnightblue=(25./255.,25./255.,112./255.)
forestgreen=(34./255.,139./255.,34./255.)
#grid
Nmesh=512
L=4.0
dx=L/Nmesh
Xmax=L
x=arange(-L,L+0.0001,dx)
Npts=len(x)
numwav=2 #number of wave function that is being drawn
V=zeros([Npts],float)
for i in range(Npts):
V[i]=x[i]**4
a=zeros([2,Npts-2],float)
wave=zeros([Npts],float)
wave1=zeros([Npts],float)
encor=3.0/4*(3.0/4)**(1.0/3)
#numerical solution
for i in range(1,Npts-1,1):
a[0,i-1]= 1.0/dx**2+V[i] #diagonal elements
a[1,i-1]=-1.0/dx**2/2 #the elements below the diagonal
a[1,Npts-3]=-99.0 #element is not used
eig,vec=eig_banded(a,lower=1) #routine that diagonalizes the tridiagonal matrix
for i in range(1,Npts-1,1):
wave[i]=vec[i-1,numwav]
wave[0]=0.0 #wave function has the value zero on the first point on the grid
wave[Npts-1]=0.0 #wave function has the value zero on the last point on the grid
wave=150*wave+eig[numwav]
#potential graph
line=plt.plot(x,V)
plt.setp(line,color='firebrick',linewidth=2)
#plot of the selected level and wave function
plt.axhline(y=eig[numwav],linewidth=2,color='steelblue')
#plot of the points of the wave function
plt.plot(x,wave,"b-",linewidth=2,color='forestgreen')
plt.xlabel('x',size=16)
plt.ylabel('V(x)',size=16)
plt.axis([-4.0,4.0,-5.0,16.0]) #x and y axes range
plt.grid(True)
plt.show()
귀하의 질문에 대한 답변을 드렸습니다 만, 귀하가 작성할 수있는 코드가 크게 개선되었습니다. 예를 들어,'range'를 사용하는 대신 numpy의 내장 벡터 연산을 사용하십시오 :'V = x ** 4'는 세 줄 모두를 대체 할 수 있습니다. –
공간적으로 불균등하게 분포 된 마커가있는 경우 마커에 대한 acrlength 매개 변수화가 필요합니다.이 매개 변수는 다음에서 해결됩니다. http://stackoverflow.com/questions/17406758/plotting-a-curve-with-equidistant-arc-length- 마커 –