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

"Minor" longitude and latitude gridlines #27

Closed
bradyrx opened this issue Aug 28, 2019 · 5 comments · Fixed by #167
Closed

"Minor" longitude and latitude gridlines #27

bradyrx opened this issue Aug 28, 2019 · 5 comments · Fixed by #167

Comments

@bradyrx
Copy link
Collaborator

bradyrx commented Aug 28, 2019

Is there any straight forward way to stride through what tick labels are shown in cartopy? Or could this be added as a feature?

This would be the equivalent of having xticks=[0,5,10,15,20] + xticklabels=['0', '', '10', '', '20'] for instance. The idea here is especially in longitude when labels get packed and overlapped at a reasonable font size for folks to see.

import numpy as np
import proplot as plot

plot.rc['geogrid.linestyle'] = ':'
plot.rc['geogrid.linewidth'] = 2
plot.rc['geogrid.color'] = '#d3d3d3'

data = np.random.rand(90, 180)
lon = np.linspace(-179.5, 179.5, 180)
lat = np.linspace(-89.5, 89.5, 90)

f, ax = plot.subplots(width='12cm', aspect=4, proj='cyl', tight=True,)

p = ax.pcolormesh(lon, lat, data, )

ax.format(latlim=(20,50), lonlim=(-135, -105), land=True,
          latlines=plot.arange(20,50,5), lonlines=plot.arange(-135,-105, 5),
          labels=True)

ax.colorbar(p, loc='r')

Screen Shot 2019-08-28 at 2 06 45 PM

This case doesn't have any issues, but imagine if you wanted the label size to be 14, 16, or 18 point font for a poster. All the lon labels overlap. Any way to show just 130W, 120W, 110W but maintain the grid structure? I figure there's a means to do it with the formatter/ticker, but I can't figure it out..

@lukelbd
Copy link
Collaborator

lukelbd commented Sep 2, 2019

Makes sense to me -- having labeled and unlabeld gridlines would be analogous to having "major" and "minor" ticklines. You could do something like lonlines=10 with minorlonlines=5. I'll implement it when I get the chance -- will just require drawing two gridliner objects.

@bradyrx
Copy link
Collaborator Author

bradyrx commented Dec 18, 2019

FYI @lukelbd, it looks like the minorlonlines keyword is gone from Axes.format. And there is no plot.rc.['gridminor.lonstep'] to access. I can't find any path forward to declare the minor grid line stepping/labeling in the current version.

@lukelbd lukelbd changed the title Easy way to stride through tick labels? "Minor" longitude and latitude gridlines Dec 18, 2019
@lukelbd
Copy link
Collaborator

lukelbd commented Dec 18, 2019

Hmm not sure that was ever a feature. Can you point to a commit? For now you can do this manually using the cartopy Gridliner.

@bradyrx
Copy link
Collaborator Author

bradyrx commented Dec 18, 2019

Oops I think I read your comment as if that was a hacky workaround with the current infrastructure.

@lukelbd
Copy link
Collaborator

lukelbd commented May 19, 2020

This is now in the master branch. Cartographic gridline properties are now controlled with the grid and gridminor rc categories (geogrid has been deprecated -- the name will be translated and a warning will be issued when you try to use it).

Also, gridline location specs like lonminorlines=X and lonlines=X are now fully interpreted by constructor.Locator(), and formatter specs are interpreted by constructor.Formatter() -- this is done by linking them to dummy _LonAxis and _LatAxis axes that track the map extent in degrees longitude/latitude -- there is no longer a need for lonstep and latstep settings since the default MaxNLocator chooses appropriate intervals given the zoom level, just like with ordinary Cartesian plots. #167 really cleaned things up a lot.

Here's an example from the website:

# %%
import proplot as plot
fig, axs = plot.subplots(
    [[1, 1, 2], [3, 3, 3]],
    axwidth=4, proj={1: 'eqearth', 2: 'ortho', 3: 'wintri'},
    wratios=(1, 1, 1.2), hratios=(1, 1.2),
)
axs.format(
    suptitle='Projection axes formatting demo',
    collabels=['Column 1', 'Column 2'],
    abc=True, abcstyle='A.', abcloc='ul', abcborder=False, linewidth=1.5
)

# Styling projections in different ways
ax = axs[0]
ax.format(
    title='Equal earth', land=True, landcolor='navy', facecolor='pale blue',
    coastcolor='gray5', borderscolor='gray5', innerborderscolor='gray5',
    gridlinewidth=1.5, gridcolor='gray5', gridalpha=0.5,
    gridminor=True, gridminorlinewidth=0.5,
    coast=True, borders=True, borderslinewidth=0.8,
)
ax = axs[1]
ax.format(
    title='Orthographic', reso='med', land=True, coast=True, latlines=10, lonlines=15,
    landcolor='mushroom', suptitle='Projection axes formatting demo',
    facecolor='petrol', coastcolor='charcoal', coastlinewidth=0.8, gridlinewidth=1
)
ax = axs[2]
ax.format(
    land=True, facecolor='ocean blue', landcolor='bisque', title='Winkel tripel',
    lonlines=60, latlines=15,
    gridlinewidth=0.8, gridminor=True, gridminorlinestyle=':',
)

tmp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants