위도 경도로 변수를 플롯하기 위해 matplotlib를 사용하고 있습니다. 문제는이 이미지에 축이나 테두리가 포함될 수 없다는 것입니다. 축을 제거 할 수 있었지만 이미지 주위의 흰색 패딩을 완전히 제거해야합니다 (아래 코드의 예제 이미지 참조 : http://imgur.com/a/W0vy9).Matplotlib 분산 형 플롯 - 흰색 패딩 제거
Remove padding from matplotlib plotting
How to remove padding/border in a matplotlib subplot (SOLVED)
Matplotlib plots: removing axis, legends and white spaces
을하지만 아무것도 공백을 제거하는 일을하지 않았다 :
나는이 StackOverflow의 방법론을 포함하여 Google 검색에서 여러 가지 방법을 시도했다. matplotlib을 버리고 다른 플로팅 라이브러리를 시도하는 경우에도 조언이 있으면 감사하겠습니다.
import numpy as np
import matplotlib
from mpl_toolkits.basemap import Basemap
from scipy import stats
lat = np.random.randint(-60.5, high=60.5, size=257087)
lon = np.random.randint(-179.95, high=180, size=257087)
maxnsz = np.random.randint(12, 60, size=257087)
percRange = np.arange(100,40,-1)
percStr=percRange.astype(str)
val_percentile=np.percentile(maxnsz, percRange, interpolation='nearest')
#Rank all values
all_percentiles=stats.rankdata(maxnsz)/len(maxnsz)
#Figure setup
fig = matplotlib.pyplot.figure(frameon=False, dpi=600)
#Basemap code can go here
x=lon
y=lat
cmap = matplotlib.cm.get_cmap('cool')
h=np.where(all_percentiles >= 0.999)
hl=np.where((all_percentiles < 0.999) & (all_percentiles > 0.90))
mh=np.where((all_percentiles > 0.75) & (all_percentiles < 0.90))
ml=np.where((all_percentiles >= 0.4) & (all_percentiles < 0.75))
l=np.where(all_percentiles < 0.4)
all_percentiles[h]=0
all_percentiles[hl]=0.25
all_percentiles[mh]=0.5
all_percentiles[ml]=0.75
all_percentiles[l]=1
rgba_low=cmap(1)
rgba_ml=cmap(0.75)
rgba_mh=cmap(0.51)
rgba_hl=cmap(0.25)
rgba_high=cmap(0)
matplotlib.pyplot.axis('off')
matplotlib.pyplot.scatter(x[ml],y[ml], c=rgba_ml, s=3, marker=',',edgecolor='none', alpha=0.4)
matplotlib.pyplot.scatter(x[mh],y[mh], c=rgba_mh, s=3, marker='o', edgecolor='none', alpha=0.5)
matplotlib.pyplot.scatter(x[hl],y[hl], c=rgba_hl, s=4, marker='*',edgecolor='none', alpha=0.6)
matplotlib.pyplot.scatter(x[h],y[h], c=rgba_high, s=5, marker='^', edgecolor='none',alpha=0.75)
fig.savefig('/home/usr/code/python/testfig.jpg', bbox_inches=0, nbins=0, transparent="True", pad_inches=0.0)
fig.canvas.draw()
당신은 [이 어떻게, 최소 완료하고 검증 가능한 예제를 만들] 읽었다 (http://stackoverflow.com/help/mcve)? – ImportanceOfBeingErnest
아니요.하지만 다른 것을 제출하기 전에 확실히 상담하겠습니다. @ImportanceOfBeingErnest 팁과 답변을 주셔서 감사합니다. 나는 많은 것을 배우고 있습니다! – mofs