Skip to content

the tick labels do not display if the center longitude is set #1923

@lwk1542

Description

@lwk1542

Description

using cartopy, the right tick labels do not display if the center_longitude is set. However, if the center_longitude is default, the right label can display.

fig, axes_arr = plt.subplots(nrows=1, ncols=1, figsize=(5.5, 3.3), subplot_kw={'projection': cartopy.crs.PlateCarree(central_longitude=180)})
image

Code to reproduce

import matplotlib.pyplot as plt
import cartopy
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
def spatdistriClass():

    size = 10
    plt.rc('font', family='Times New Roman', weight='normal', size=size)

    fig, axes_arr = plt.subplots(nrows=1, ncols=1, figsize=(5.5, 3.3),
                                 subplot_kw={'projection': cartopy.crs.PlateCarree(central_longitude=180)})
    # central_longitude=180
    ax1 = axes_arr
    ax1.coastlines('10m', color="grey", linewidth=0.1)
    ax1.add_feature(cartopy.feature.LAND.with_scale('10m'), facecolor='grey', edgecolor='none')
    ax1.set_adjustable('datalim')
    ax1.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False)
    # gl = ax1.gridlines(crs=cartopy.crs.PlateCarree(), draw_labels=["right", "left", "top", "bottom"],
    #                    linewidth=1, color='slategrey', alpha=1, linestyle='--')
    # gl.top_labels = True
    # gl.right_labels = True
    # gl.left_labels = True
    # gl.xformatter = LONGITUDE_FORMATTER
    # gl.yformatter = LATITUDE_FORMATTER
    # gl.ylabel_style = {'rotation': 90}
    plt.savefig("image.jpeg")
    plt.show()
    plt.close()
    return " "


if __name__ == '__main__':
    spatdistriClass()

Traceback


Full environment definition

Operating system

Cartopy version

conda list

pip list

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions