Commit 5cba2e60 authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Modified draw_graticule method of LayeredBasemap to plot only ticks if...

Modified draw_graticule method of LayeredBasemap to plot only ticks if graticule line width is zero.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/mapping/layeredbasemap/trunk@7715 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent 251e892a
......@@ -2089,7 +2089,7 @@ class LayeredBasemap:
"""
Draw meridians and parallels according to :prop:`graticule_style`
"""
# TODO: find a way to plot only ticks and/or parallel/meridian intersections
# TODO: find a way to plot only parallel/meridian intersections
if self.graticule_style:
#if abs(self.region[1] - self.region[0]) == 360:
# labelstyle = "+/-"
......@@ -2103,6 +2103,19 @@ class LayeredBasemap:
first_meridian = np.ceil(self.region[0] / self.dlon) * self.dlon
last_meridian = np.floor(self.region[1] / self.dlon) * self.dlon + self.dlon
meridians = np.arange(first_meridian, last_meridian, self.dlon)
line_style = meridian_style.line_style
if line_style.line_width == 0:
## Plot only ticks
## see https://stackoverflow.com/questions/18363987/basemap-how-to-remove-actual-lat-lon-lines-while-keeping-the-ticks-on-the-axis/62087643#62087643
# convert from degree to map projection
lon_ticks_proj, _ = self.map(meridians, np.zeros(len(meridians)))
# manually add ticks
self.ax.set_xticks(lon_ticks_proj)
self.ax.tick_params(axis='x', which='major', length=6, width=1, direction='in')
# add ticks to the opposite side as well
self.ax.xaxis.set_ticks_position('both')
# remove the tick labels
self.ax.xaxis.set_ticklabels([])
self.map.drawmeridians(meridians, zorder=self.zorder, **style_kwargs)
if self.dlat != None:
parallel_style = self.graticule_style.copy()
......@@ -2112,6 +2125,18 @@ class LayeredBasemap:
first_parallel = np.ceil(self.region[2] / self.dlat) * self.dlat
last_parallel = np.floor(self.region[3] / self.dlat) * self.dlat + self.dlat
parallels = np.arange(first_parallel, last_parallel, self.dlat)
line_style = parallel_style.line_style
if line_style.line_width == 0:
## Plot only ticks
# convert from degree to map projection
_, lat_ticks_proj = self.map(np.zeros(len(parallels)), parallels)
# manually add ticks
self.ax.set_yticks(lat_ticks_proj)
self.ax.tick_params(axis='y', which='major', length=6, width=1, direction='in')
# add ticks to the opposite side as well
self.ax.yaxis.set_ticks_position('both')
# remove the tick labels
self.ax.yaxis.set_ticklabels([])
self.map.drawparallels(parallels, zorder=self.zorder, **style_kwargs)
self.zorder += 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment