CATTOPY无法显示Eckertiii投影的纬度标签
Cartopy并未在简单的图中显示纬度标签。 可以设置什么以显示纬度标签? 这些代码将创建图形,但未显示LAT标签。 如果将投影更改为Platecarree,则没有问题可以显示标签。
Python代码是:
# Setup a global EckertIII map with faint coastlines.
fig = plt.figure(figsize=(16, 8))
ax = fig.add_subplot(2,2,1, projection=ccrs.EckertIII())
# ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
x = np.arange(-90, 90)
y = x.copy()
x2, y2 = np.meshgrid(x, y)
z = x2*y2
filled_c = ax.contourf(x2, y2, z, transform=ccrs.PlateCarree())
line_c = ax.contour(x2, y2, z, levels=filled_c.levels,
colors=['black'],
transform=ccrs.PlateCarree())
plt.colorbar(filled_c, orientation='vertical', ax=ax)
ax.set_global()
ax.coastlines('110m', alpha=0.1)
# Use the line contours to place contour labels.
ax.clabel(
line_c, # Typically best results when labelling line contours.
colors=['black'],
manual=False, # Automatic placement vs manual placement.
inline=True, # Cut the line where the label will be placed.
fmt=' {:.0f} '.format, # Labes as integers, with some extra space.
)
# # s0
# ax.gridlines(color='k', linestyle='--', draw_labels=True)
# # s1
gl = ax.gridlines(
xlocs=[-180, -120, -60, 0, 60, 120, 180],
ylocs=[-90, -60, -30, 0, 30, 60, 90],
draw_labels=True, x_inline=False, y_inline=False,
lw=0.5, linestyle='--', color='gray'
)
# gl.top_labels = False
# gl.right_labels = True
gl.rotate_labels = False
Cartopy is not showing latitude labels in a simple plot.
What can be set to show the latitude labels?
The codes will create the figure, but the lat labels not shown.
If change the projection to PlateCarree, then there is no problem to show labels.
The python code is:
# Setup a global EckertIII map with faint coastlines.
fig = plt.figure(figsize=(16, 8))
ax = fig.add_subplot(2,2,1, projection=ccrs.EckertIII())
# ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
x = np.arange(-90, 90)
y = x.copy()
x2, y2 = np.meshgrid(x, y)
z = x2*y2
filled_c = ax.contourf(x2, y2, z, transform=ccrs.PlateCarree())
line_c = ax.contour(x2, y2, z, levels=filled_c.levels,
colors=['black'],
transform=ccrs.PlateCarree())
plt.colorbar(filled_c, orientation='vertical', ax=ax)
ax.set_global()
ax.coastlines('110m', alpha=0.1)
# Use the line contours to place contour labels.
ax.clabel(
line_c, # Typically best results when labelling line contours.
colors=['black'],
manual=False, # Automatic placement vs manual placement.
inline=True, # Cut the line where the label will be placed.
fmt=' {:.0f} '.format, # Labes as integers, with some extra space.
)
# # s0
# ax.gridlines(color='k', linestyle='--', draw_labels=True)
# # s1
gl = ax.gridlines(
xlocs=[-180, -120, -60, 0, 60, 120, 180],
ylocs=[-90, -60, -30, 0, 30, 60, 90],
draw_labels=True, x_inline=False, y_inline=False,
lw=0.5, linestyle='--', color='gray'
)
# gl.top_labels = False
# gl.right_labels = True
gl.rotate_labels = False
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己解决了该数字两次的网格电话,我自己解决了问题。
第一次运行设置为旋转标签TRUE,然后将第二次运行设置为此False。
然后,将为他们绘制网格线。
I solved the problem myself, by running gridlines for the figure twice.
First run is set rotate labels True, and 2nd run is set this False.
Then the gridlines will be drawn for them.