Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot customize xlabels/ylabels locations with SouthPolarStereo #1576

Closed
jeffreymei opened this issue Jun 2, 2020 · 3 comments
Closed

cannot customize xlabels/ylabels locations with SouthPolarStereo #1576

jeffreymei opened this issue Jun 2, 2020 · 3 comments

Comments

@jeffreymei
Copy link

Description

So according to https://scitools.org.uk/cartopy/docs/v0.13/matplotlib/gridliner.html you can customize whether the right/left or top/bottom borders of the plot have tick labels on them by using gl.xlabels_top = False. But this gives no effect with SouthPolarStereo - it does work with Mercator.

Code to reproduce

ax = plt.subplot(111, projection=ccrs.SouthPolarStereo())
land = cfeature.NaturalEarthFeature('physical', 'land', '50m')
polar_crs = ccrs.SouthPolarStereo()
polar_extent = [-15, -120, -80, -66]
gl = ax.gridlines(color='lightgrey', linestyle='-', draw_labels=True, x_inline =False, y_inline =True)
ax.set_extent(polar_extent, crs=ccrs.PlateCarree())
gl.ylocator = mticker.FixedLocator([-85, -80, -75, -70, -65])
gl.xlocator = mticker.FixedLocator(np.arange(-160, 0, 20))
gl.ylabels_right = False
ax.xaxis.set_ticks([])
ax.add_feature(land, facecolor='#AAAAAA')
plt.show()

E.g. below, I don't want the longitude labels on the right border.
Figure_1

Cartopy version

0.18, with Python 3.6.7.

@kdpenner
Copy link
Contributor

This is a problem also with Albers Equal Area and the new right_labels and top_labels attributes.

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import cartopy.crs as ccrs

plt_crs = ccrs.AlbersEqualArea(central_longitude=151.515,
                               central_latitude=53.27)
ax = plt.subplot(1, 1, 1, projection=plt_crs)
extent = [133.61, 169.42, 43.23, 63.31]
gl = ax.gridlines(draw_labels=True)
ax.set_extent(extent, crs=ccrs.PlateCarree())
gl.ylocator = mticker.FixedLocator(np.arange(43.23, 90, 10))
gl.xlocator = mticker.FixedLocator(np.arange(133.61, 180, 20))
gl.right_labels = False
gl.top_labels = False
plt.show()

t

@greglucas
Copy link
Contributor

This is currently being worked on and discussed in the PR #1537. Also see #1530 for a similar request/discussion and feel free to weigh in with your thoughts on implementation details there as well.

A quick fix that I've used in the past is to add multiple gridliners to the axes and customize them with different lat/lon ranges and label visibilities, but it is a much more manual process of defining exactly the desired result, so not optimal.

@QuLogic
Copy link
Member

QuLogic commented Sep 10, 2021

Closed by #1537

@QuLogic QuLogic closed this as completed Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants