-
Notifications
You must be signed in to change notification settings - Fork 101
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
Show grid ticks on geographic plots #227
Comments
This method of retrieving gridline ticks may be useful for adding the function:
|
You can monitor #253 for updates Please also note the padding you see in that example is a cartopy bug confusing "pixels" with "points". It was fixed in SciTools/cartopy#1556. You can upgrade to cartopy v0.19 to get nicely-padded labels or play with |
Hi, maybe try
|
kM-Stone's solution does not work properly for some other projections such as 'gnom'.
I found a temporary workaround for general projections. I put it here in case it is helpful for anyone. import numpy as np
import proplot as pplt
def add_ticks(ax, labelpad=None):
"""Only works for major ticks on the left and bottom."""
ax.grid(False)
ax.tick_params('both', which='major', size=pplt.rc['tick.len'])
if labelpad is None:
labelpad = pplt.rc['tick.len'] + 2
for gl in ax._gridliners:
gl.xpadding = gl.ypadding = labelpad
ax.format(labelpad=labelpad)
ax.figure.canvas.draw_idle() # necessary for generating xlabel_artists...
for gl in ax._gridliners:
xy = np.array([t.get_position() for t in gl.bottom_label_artists if t.get_visible()])
if xy.any():
ax.set_xticks(xy[:, 0])
ax.set_xticklabels([])
xy = np.array([t.get_position() for t in gl.left_label_artists if t.get_visible()])
if xy.any():
ax.set_yticks(xy[:, 1])
ax.set_yticklabels([])
fig = pplt.figure(span=False, suptitle='Example')
ax = fig.subplot(111, proj='gnom', proj_kw={'lon_0': 0, 'lat_0': 45})
ax.format(lonlim=(-20, 20), latlim=(30, 60),
labels=True, grid=True, gridminor=True,
lonlocator=np.arange(-50, 50, 5), latlocator=5,
)
add_ticks(ax) |
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
Expected behavior: [What you expected to happen]
Ticks without gridlines.
I found one example showing ticks with Gridlines:
Actual behavior: [What actually happened]
Can't let ticks show.
Proplot version
0.6.4
The text was updated successfully, but these errors were encountered: