1

所以我正在运行这段代码来绘制地图,无论我尝试什么,我都无法摆脱 0 到 1 的丑陋盒子/框架。当我摆脱图形框架时,它指的是内部的我想保留的纬度/经度。

df = days_dict[t]
    proj = ccrs.PlateCarree()
    ax = plt.axes(projection=proj)
    bounds = [-125.0011, -66.9326, 49.5904, 24.9493]
    ax.set_extent(bounds, crs=ccrs.PlateCarree())

    im = ax.scatter(df['long'], df['lat'], c=df['mean_no2'], s=8, cmap=cm.bwr, vmin=0, vmax=40)
    cartography(ax)
    
    axins = inset_axes(ax, width="90%", height="10%", loc='lower center', borderpad=-3)
    
    cbar = plt.colorbar(im, label='NO2 concentration (ppb)', orientation='horizontal', cax=axins, fraction=0.046, norm=norm, anchor=(0.5, -1))
    cbar.set_ticks(np.arange(0, 40, 10))
    plt.show()
    fig = plt.gcf()
    fig.bbox_inches='tight'
    
    fig.frameon = False
    axins.frameon = False
    out_name = out_folder + '\\frame%s.png' % t
    
    fig.savefig(out_name)
    fig.clear()

我想要内部框架,而不是外部框架。我怎样才能摆脱这个?

在此处输入图像描述

4

2 回答 2

0

类似问题:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

proj = ccrs.NorthPolarStereo(true_scale_latitude = 75)
fig, ax = plt.subplots(figsize=(8,6))
ax = plt.axes(projection=proj)
ax.coastlines('10m')
ax.set_extent([-180, 180, 65, 90], crs=ccrs.PlateCarree())

奇怪的框架

解决方案:

fig,ax = plt.subplots(figsize=(8,6), subplot_kw={"projection": ccrs.NorthPolarStereo(true_scale_latitude = 75)})
    ax.coastlines('10m')
    ax.set_extent([-180, 180, 65, 90], crs=ccrs.PlateCarree())

没有奇怪的框架

于 2021-12-07T10:12:57.290 回答
0

问题出现cartography(ax)在您的代码中。只需用这行代码替换它:-

ax.gridlines(xlocs=range(-180,180,10),ylocs=range(-90, 90, 10),color='black',linestyle='dotted',draw_labels=True)
于 2021-10-21T21:56:25.660 回答