cartopy icon indicating copy to clipboard operation
cartopy copied to clipboard

BUG: gridliner vs dateline

Open bblay opened this issue 11 years ago • 4 comments

Using the gridliner across the dateline, it fails in one of two ways. Either the labels aren't printed beyond dateline, or the lines don't join up across the dateline.

import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER


def plot_common(subp, title):
    ax = plt.subplot(subp, projection=ccrs.PlateCarree(central_longitude=141.0))
    ax.set_extent([100, 205, 15, 50])
    ax.coastlines()

    gl = ax.gridlines(draw_labels=True, linewidth=0.5, alpha=0.7)
    gl.top_labels = False
    gl.right_labels = False

    gl.ylocator = mticker.FixedLocator([10,30,50,70,90])
    gl.xformatter = LONGITUDE_FORMATTER
    gl.yformatter = LATITUDE_FORMATTER

    pc = ccrs.PlateCarree()
    sf = plt.plot(141.0329,37.4206,'r*',markersize=10,transform=pc)
    st = plt.text(141.1329,37.4206,'Fukushima \n Dai-ichi NPP',verticalalignment='top',transform=pc)

    plt.title(title)

    return gl


# broken ticks
gl = plot_common(211, 'broken ticks')
gl.xlocator = mticker.FixedLocator([100,120,140,160,180,200,220])


# broken lines
gl = plot_common(212, 'broken lines')
gl.xlocator = mticker.FixedLocator([100,120,140,160,180,-160,-140])


plt.show()

bblay avatar May 23 '13 12:05 bblay

Is this still unfixed?

acrosby avatar Jun 14 '18 18:06 acrosby

Still unfixed on master (v0.17 just released).

figure_1

pelson avatar Dec 05 '18 01:12 pelson

The gridlines now continue through the dateline on master. However, the ticks still don't wrap properly.

greglucas avatar Apr 26 '20 20:04 greglucas

The default CRS for GeoAxes.gridlines is PlateCarree, not the map CRS, so longitudes > 180 do not exist. But if we pass the map CRS, then the central longitude becomes 0, which is also not what we want. I guess gridlines should do some sort of wrapping, but it should only be a special case, maybe just for PlateCarree or geodetic CRSs? Or maybe this is another case for LatLong #1164.

QuLogic avatar Apr 26 '20 20:04 QuLogic