小编Hol*_*weg的帖子

MatplotLib'saveFig()'全屏

我使用MatplotLib和Cartopy生成一些数据图像.问题是,当我将帧大小设置为全屏并使用plt.show()时,图像是完美的,分辨率很好.

但是,当我使用'plt.savefig()'保存此图时,保存的图像保持原始大小(不是全屏).

显示结果图像:

显示图像 - 不保存它

保存图像 - 不显示图像

我的代码如下:

def plot_tec_cartopy(descfile):global matrixLon,matrixLat,matrixTec

ax = plt.axes(projection=cartopy.crs.PlateCarree())

v = np.linspace(0, 80, 46, endpoint=True)
cp = plt.contourf(matrixLon, matrixLat, matrixTec, v, cmap=plt.cm.rainbow)
plt.clim(0, 80)
plt.colorbar(cp)

ax.add_feature(cartopy.feature.COASTLINE)
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.set_extent([-85, -30, -60, 15])

# Setting X and Y labels using LON/LAT format
ax.set_xticks([-85, -75, -65, -55, -45, -35])
ax.set_yticks([-60, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15])
lon_formatter = LongitudeFormatter(number_format='.0f',
                                   degree_symbol='',
                                   dateline_direction_label=True)
lat_formatter = LatitudeFormatter(number_format='.0f',
                                  degree_symbol='')
ax.xaxis.set_major_formatter(lon_formatter)
ax.yaxis.set_major_formatter(lat_formatter)

plt.title('Conteúdo Eletrônico Total', style='normal', fontsize='12') …
Run Code Online (Sandbox Code Playgroud)

python matplotlib cartopy

10
推荐指数
1
解决办法
5650
查看次数

标签 统计

cartopy ×1

matplotlib ×1

python ×1