突然間,可能在一些模塊更新之后,我得到了一個額外的框/框架,在我的 Cartopy 地圖周圍帶有 x (0,1) 和 y (0,1) 軸。我如何洗掉它?
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
#Set the projection information
proj = ccrs.NorthPolarStereo(true_scale_latitude = 75)
#Create a figure with an axes object on which we will plot. Pass the projection to that axes.
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())
Cartopy 圖周圍奇怪的額外框架
我試過了:
ax.axis('off')
right_side = ax.spines["right"]
right_side.set_visible(False)
plt.box(False)
plt.xticks([])
plt.yticks([])
plt.box(on=None)
任何其他想法將不勝感激。
這是一個類似的問題:How to remove the frame around my Cartopy/Matplotlib plot
uj5u.com熱心網友回復:
這解決了這個問題:
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
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())
uj5u.com熱心網友回復:
我第一次在這里回答。如果您有多個 Axes(ax1, ax2),這會清除投影邊界并且不會溢位
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
#Set the projection information
proj = ccrs.NorthPolarStereo(true_scale_latitude=75)
#create fig, add 1 or more subplots and declare projection frameon status
fig = plt.figure(figsize=(8, 6), )
ax = fig.add_subplot(projection=proj, frameon=False)
ax.coastlines('10m')
ax.set_extent([-180, 180, 65, 90], crs=ccrs.PlateCarree())
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/376617.html
標籤:Python matplotlib 框架 轴 卡托皮
