【问题标题】:Is there a way to make gridline labels appear on only one set of axes?有没有办法让网格线标签只出现在一组轴上?
【发布时间】:2021-10-13 14:03:32
【问题描述】:

我正在使用 matplotlib.pyplot 制作地图,并使用网格线功能在纬度和经度的 x 和 y 轴上创建“标签”。我将网格线颜色设置为“无”以避免出现网格线。但是,这些标签出现在绘图的每一侧,并且在某一点上与我的颜色条重合。有没有办法让这些网格线标签只出现在图的底部和左侧?我在任何地方都找不到可用的 kwargs 列表。这是我使用的代码:

ax.gridlines(draw_labels=True, color="none")

这是地图的图像。理想情况下,我想删除右轴和上轴上的度数标签。

【问题讨论】:

标签: python matplotlib gis cartopy


【解决方案1】:

您可以使用这些相关代码实现您所需要的:-

# minor change to the existing line of code
gls = ax.gridlines(draw_labels=True, color="none")

# other lines of code

# add these before plotting
gls.top_labels=False   # suppress top labels
gls.right_labels=False # suppress right labels

【讨论】:

    猜你喜欢
    • 2018-06-05
    • 2021-03-26
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 2019-09-12
    • 2019-12-29
    • 2019-11-06
    • 1970-01-01
    相关资源
    最近更新 更多