Skip to content

Show grid ticks on geographic plots #227

Description

@zxdawn

Description

Currently, only grid_lines is supported for geographic plots.
It would be useful to add the grid_ticks for cleaner plot.

Steps to reproduce

import proplot as plot

fig, axs = plot.subplots(proj='cyl')
axs.format(land=True,
           labels=True,
           lonlines=20,
           latlines=20,
           gridminor=True,
           lonlim=(-140, 60),
           latlim=(-10, 50))

Expected behavior: [What you expected to happen]

Ticks without gridlines.

I found one example showing ticks with Gridlines:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter

dlon, dlat = 60, 30
xticks = np.arange(0, 360.1, dlon)
yticks = np.arange(-90, 90.1, dlat)

fig = plt.figure(figsize=(6,5))
ax = fig.add_subplot(1,1,1, projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines() #海岸线

gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=False,linewidth=1, linestyle=':', color='k', alpha=0.8)
gl.xlocator = mticker.FixedLocator(xticks)
gl.ylocator = mticker.FixedLocator(yticks)

ax.set_xticks(xticks, crs=ccrs.PlateCarree())
ax.set_yticks(yticks, crs=ccrs.PlateCarree())

ax.xaxis.set_major_formatter(LongitudeFormatter(zero_direction_label=True))
ax.yaxis.set_major_formatter(LatitudeFormatter())

image

Actual behavior: [What actually happened]
Can't let ticks show.
test_tick

Proplot version

0.6.4

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions