question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Minor" longitude and latitude gridlines

See original GitHub issue

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…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
lukelbdcommented, 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

0reactions
bradyrxcommented, Dec 18, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Latitude, Longitude and Coordinate System Grids
Here's how you can remember latitude and longitude: Latitude lines run east-west and are parallel to each other. If you go north, latitude ......
Read more >
latitude and longitude - Students | Homework Help
Commonly called a grid system, it is made up of two sets of lines that cross each other. One set—lines of latitude—runs in...
Read more >
Graticules—ArcGIS Pro | Documentation
Gridlines are the lines crossing over the map that delineate degrees of latitude and longitude. By default, the gridline intervals are calculated based...
Read more >
Graticules and Grids | Map-N-Hike
The latitude/longitude grid is based on a sphere and is familiar to most people. Lines of latitude go around the world parallel to...
Read more >
Graticules
The Graticules grid option places grid lines at specific intervals of latitude and longitude (in degrees). Specify the interval for lines of latitude...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found