Skip to content

Commit 33a9d9a

Browse files
committed
implemented inverse transform for Mollweide axes
1 parent 9c60c58 commit 33a9d9a

File tree

1 file changed

+10
-2
lines changed
  • lib/matplotlib/projections

1 file changed

+10
-2
lines changed

lib/matplotlib/projections/geo.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,16 @@ def __init__(self, resolution):
476476
self._resolution = resolution
477477

478478
def transform_non_affine(self, xy):
479-
# MGDTODO: Math is hard ;(
480-
return xy
479+
x = xy[:, 0:1]
480+
y = xy[:, 1:2]
481+
482+
# from Equations (7, 8) of
483+
# http://mathworld.wolfram.com/MollweideProjection.html
484+
theta = np.arcsin(y / np.sqrt(2))
485+
lon = (np.pi / (2 * np.sqrt(2))) * x / np.cos(theta)
486+
lat = np.arcsin((2 * theta + np.sin(2 * theta)) / np.pi)
487+
488+
return np.concatenate((lon, lat), 1)
481489
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
482490

483491
def inverted(self):

0 commit comments

Comments
 (0)