Permalink
Browse files

implemented inverse transform for Mollweide axes

  • Loading branch information...
1 parent 9c60c58 commit 33a9d9ac7cbf3eafb065bafcdc4e067c7172fa75 @lpsinger lpsinger committed Dec 27, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/matplotlib/projections/geo.py
View
12 lib/matplotlib/projections/geo.py
@@ -476,8 +476,16 @@ def __init__(self, resolution):
self._resolution = resolution
def transform_non_affine(self, xy):
- # MGDTODO: Math is hard ;(
- return xy
+ x = xy[:, 0:1]
+ y = xy[:, 1:2]
+
+ # from Equations (7, 8) of
+ # http://mathworld.wolfram.com/MollweideProjection.html
+ theta = np.arcsin(y / np.sqrt(2))
+ lon = (np.pi / (2 * np.sqrt(2))) * x / np.cos(theta)
+ lat = np.arcsin((2 * theta + np.sin(2 * theta)) / np.pi)
+
+ return np.concatenate((lon, lat), 1)
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
def inverted(self):

0 comments on commit 33a9d9a

Please sign in to comment.