proplot-dev / proplot

🎨 A succinct matplotlib wrapper for making beautiful, publication-quality graphics
https://proplot.readthedocs.io
MIT License
1.07k stars 96 forks source link

Missing 180 degree label in 'npaeqd' projection #417

Open 664787022 opened 1 year ago

664787022 commented 1 year ago

Description

When I set proj='npaeqd', proplot 0.9.7 does not show all longitude labels, but only far bottom label . This problem does not exists in 0.9.5.post332.

import proplot as pplt
import numpy as np

fig, ax = pplt.subplots(ncols=2, nrows=2, proj='npaeqd', share=False)
ax.format(labels=True, coast=True,
          lonlocator=np.arange(-180,180+30,30))

image

Steps to reproduce

import proplot as pplt
import numpy as np

fig, ax = pplt.subplots(ncols=2, nrows=2, proj='npaeqd', share=False)
ax.format(labels=True, coast=True,
          lonlocator=np.arange(-180,180+30,30))

Expected behavior:   show longitude labels as in proplot 0.9.5.post332   image


  By the way, how can I make longitude labels like this as in cartopy? ( showing far top label 180° compared to picture 2)  

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import matplotlib.path as mpath
import numpy as np

fig = plt.figure(figsize=[10, 5])
ax1 = fig.add_subplot(1, 2, 1, projection=ccrs.NorthPolarStereo())

leftlon, rightlon, lowerlat, upperlat = (-180,180,0,90)
ax1.set_extent([leftlon, rightlon, lowerlat, upperlat], ccrs.PlateCarree())

# add labels
ax1.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
              xlocs = np.arange(-180,180+30,30), 
              linewidth=1, color='grey',linestyle='--')

# set the boundary
theta = np.linspace(0, 2*np.pi, 100)
center, radius = [0.5, 0.5], 0.5
verts = np.vstack([np.sin(theta), np.cos(theta)]).T
circle = mpath.Path(verts * radius + center)
ax1.set_boundary(circle, transform=ax1.transAxes)

image

  Actual behavior: Only showing the far bottom label as in picture 1.

Equivalent steps in matplotlib

import proplot as pplt
import numpy as np

fig, ax = pplt.subplots(ncols=2, nrows=2, proj='npaeqd',share=False)
ax.format(labels=True, coast=True,
          lonlocator=np.arange(-180,180+30,30))

Proplot version

matplotlib 3.4.3 proplot 0.9.7 cartopy 0.20.2

lukelbd commented 1 year ago

Hi there -- it's a little confusing, but the 0.9.5.postXYZ versions you get from installing "dev" are actually newer than 0.9.7. I just created 0.9.7 by going back in the version history to the last release, creating a branch, and enforcing a maximum matplotlib version in setup.cfg on that branch, so that people installing stable versions of proplot for the first time get compatible matplotlib versions (see #309 -- think this is common practice for other packages... but took me a long time to figure out). It doesn't show 0.9.7.postXYZ when you install "dev" just because 0.9.7 lives on a separate branch.

So, this is already fixed :). And re: cartopy grid labels, you can pass rotatelabels=True to format() or set pplt.rc['grid.rotatelabels'] = True. Proplot just picks a different default behavior there.

664787022 commented 1 year ago

Hi there -- it's a little confusing, but the 0.9.5.postXYZ versions you get from installing "dev" are actually newer than 0.9.7. I just created 0.9.7 by going back in the version history to the last release, creating a branch, and enforcing a maximum matplotlib version in setup.cfg on that branch, so that people installing stable versions of proplot for the first time get compatible matplotlib versions (see #309 -- think this is common practice for other packages... but took me a long time to figure out). It doesn't show 0.9.7.postXYZ when you install "dev" just because 0.9.7 lives on a separate branch.

So, this is already fixed :). And re: cartopy grid labels, you can pass rotatelabels=True to format() or set pplt.rc['grid.rotatelabels'] = True. Proplot just picks a different default behavior there.

Thanks a lot! I do not know much about branch management and sorry for bothering. What I am actually confused in my second question is that proplot lost the far top longitude label 180°. Is there a way to add 180° as in Cartopy? 图片2

lukelbd commented 1 year ago

Hmm not sure about that. I'll re-open