0
othographic投影の小さな領域を(savefig()を使用して)ファイルに保存しようとしています。 plt.show()を使用したプロットは正しい領域を表示しますが、保存された(plt.savefig()を使用して)ディスク全体の領域が中央に小さなスケールで表示されます。matplotlib basemap othographic projection保存されたファイルが表示されている領域と異なる領域をカバーしています
下の左の画像は、表示される正しい領域を示しています。右側の画像は、選択された領域が中央に縮小された完全な地球のディスクを示しています。
画像ファイルに選択した領域を保存する方法を教えていただければ幸いです。
from mpl_toolkits.basemap import Basemap
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.lines as lines
import numpy as np
lon_0 = 5.0
lat_0 = 45.0
max_lat = lat_0 + 10.0
min_lat = lat_0 - 10.0
max_lon = lon_0 + 15.0
min_lon = lon_0 - 15.0
plt.figure(figsize=(6,6))
my_map = Basemap(projection='ortho', lon_0=lon_0, lat_0=lat_0, resolution='l')
my_map.drawcoastlines()
my_map.drawcountries()
my_map.drawparallels(np.arange(-90.,95.,5.))
my_map.drawmeridians(np.arange(0.,365.,5.))
xmin, ymin = my_map(min_lon, min_lat)
xmax, ymax = my_map(max_lon, max_lat)
my_map.plot([xmin, xmax], [ymin, ymax], marker=None,color='m') # plot a cross
my_map.plot([xmin, xmax], [ymax, ymin], marker=None,color='m')
ax = plt.gca() # set the axes limits
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
output_file = 'example_a.png'
plt.savefig(output_file, bbox_inches='tight', dpi=20) # save image
plt.show()
plt.close('all')
z.fox私は正しい方向に向いてくれてありがとうございます。 – KirbyJames