[GRASS-SVN] r69786 - grass-addons/grass7/vector/v.faultdirections
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 7 07:43:05 PST 2016
Author: mlennert
Date: 2016-11-07 07:43:05 -0800 (Mon, 07 Nov 2016)
New Revision: 69786
Modified:
grass-addons/grass7/vector/v.faultdirections/v.faultdirections.py
Log:
v.faultdirections: correct bug in label heuristics when only very few lines per direction
Modified: grass-addons/grass7/vector/v.faultdirections/v.faultdirections.py
===================================================================
--- grass-addons/grass7/vector/v.faultdirections/v.faultdirections.py 2016-11-06 22:10:32 UTC (rev 69785)
+++ grass-addons/grass7/vector/v.faultdirections/v.faultdirections.py 2016-11-07 15:43:05 UTC (rev 69786)
@@ -81,10 +81,15 @@
ax = plt.subplot(111, projection='polar')
ax.set_theta_direction(-1)
ax.set_theta_offset(np.pi/2.0)
- base = 5 if max(radii) > 10 else 2
- labelstep = round((max(radii) - min(radii)) / 5)
- labelstep = int(base * round(float(labelstep) / base))
- labelradii = [x for x in np.arange(0, int(np.ceil(max(radii))), labelstep) if x > 0]
+ unique_radii = [x for x in set(radii) if x > 0]
+ range_radii = max(radii) - min(radii)
+ if range_radii > 4:
+ base = 5 if max(radii) > 10 else 2
+ labelstep = np.ceil((range_radii) / 5)
+ labelstep = int(base * round(labelstep / base))
+ labelradii = [x for x in np.arange(0, int(np.ceil(max(radii))), labelstep) if x > 0]
+ else:
+ labelradii = unique_radii
ax.set_rgrids(labelradii, angle=legend_angle)
ax.text(legend_angle*(np.pi/180), max(radii)*1.1, label)
bars = ax.bar(theta, radii, width=width, bottom=0.0)
More information about the grass-commit
mailing list