, 나는베이스 맵 객체 인스턴스화 내용과 중첩되는 방법을 볼 수 있습니다matplotlib - Basemap 객체와 상호 작용하는 실제 PyPlot 객체가 있습니까? <a href="http://matplotlib.org/basemap/users/examples.html" rel="nofollow">Basemap docs</a> 보면
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
map = Basemap(projection='ortho',lat_0=45,lon_0=-100,resolution='l')
map.drawcoastlines(linewidth=0.25)
...
개체가 map
라는 이름의 다양한 기본지도 방법이 행동한다. 그러나 나중에 동일한 코드에서 PyPlot (plt
으로 가져옴)이 어떻게 작동하는지 이해할 수 없습니다. 이 뚜렷한 PyPlot 개체 수없는 것, 그리고 PyPlot 모듈에 대한 호출은 결코 map
을 언급하지 :
# make up some data on a regular lat/lon grid.
nlats = 73; nlons = 145; delta = 2.*np.pi/(nlons-1)
lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0,:,:])
lons = (delta*np.indices((nlats,nlons))[1,:,:])
wave = 0.75*(np.sin(2.*lats)**8*np.cos(4.*lons))
mean = 0.5*np.cos(2.*lats)*((np.sin(2.*lats))**2 + 2.)
# compute native map projection coordinates of lat/lon grid.
x, y = map(lons*180./np.pi, lats*180./np.pi)
# contour data over the map.
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
plt.title('contour lines over filled continent background')
plt.show()
어떻게 어디 PyPlot는 map
객체와 상호 작용합니까?
하단의 세 번째 코드 줄에서 변수 cs
이 할당되는 이유는 코드의 다른 곳에서 실제로 사용되지 않았기 때문입니다. cs =
을 제거한 출력 결과에는 차이가 없습니다.