Skip to content
Snippets Groups Projects
Commit 693af80a authored by Martin Schrön's avatar Martin Schrön
Browse files

Improved tick clutter in for latlon plots

parent 308a0332
No related branches found
No related tags found
No related merge requests found
......@@ -366,22 +366,31 @@ def add_scalebar(ax, length=1, location=(0.89, 0.04),
# buffer for scalebar
buffer = [patheffects.withStroke(linewidth=1, foreground=color)]
# Plot the scalebar with buffer
ax.plot(bar_xs, [sbcy_1, sbcy_1], transform=utm, color='k',
linewidth=linewidth, path_effects=buffer)
ax.plot(
bar_xs, [sbcy_1, sbcy_1],
transform=utm,
color='k', linewidth=linewidth,
path_effects=buffer)
# buffer for text
buffer = [patheffects.withStroke(linewidth=1, foreground=color)]
# Plot the scalebar label
t0 = ax.text(sbcx_1, sbcy_2, str(length) + ' ' + units, transform=utm,
t0 = ax.text(
sbcx_1, sbcy_2, str(length) + ' ' + units,
transform=utm,
horizontalalignment='right', verticalalignment='bottom',
color=color, zorder=2) #path_effects=buffer
left = x0+(x1-x0)*0.03
# Plot the N arrow
t1 = ax.text(sbcx_1, y_ur, u'\u25B2\nN', transform=utm,
horizontalalignment='right', verticalalignment='top',
t1 = ax.text(
sbcx_1, y_ur, u'\u25B2\nN',
transform=utm,
horizontalalignment='right',
verticalalignment='top',
color=color, zorder=2)
# Plot the scalebar without buffer, in case covered by text buffer
ax.plot(bar_xs, [sbcy_1, sbcy_1], transform=utm, color=color,
ax.plot(bar_xs, [sbcy_1, sbcy_1], transform=utm,
color=color,
linewidth=linewidth, zorder=3)
def guess_ticks_from_lim(a, b, steps=None):
......@@ -411,8 +420,16 @@ def add_latlon_ticks(ax, steps=0.01, grid=True):
ys = guess_ticks_from_lim(extent[2], extent[3], steps)
ax.set_xticks(xs)
ax.set_yticks(ys)
ax.set_xticklabels(["%.3f°" % x for x in xs])
ax.set_yticklabels(["%.3f°" % y for y in ys])
xlabels = np.array(["%.3f°" % x for x in xs])
if len(xlabels) > 7:
xlabels[1::3] = ""
xlabels[2::3] = ""
ylabels = np.array(["%.3f°" % y for y in ys])
if len(ylabels) > 7:
ylabels[1::3] = ""
ylabels[2::3] = ""
ax.set_xticklabels(xlabels)
ax.set_yticklabels(ylabels)
ax.set_xlabel(None)#'Longitude (°E)')
ax.set_ylabel(None)#'Latitude (°N)')
if grid:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment