@@ -385,9 +385,10 @@ class HammerTransform(Transform):
385385 output_dims = 2
386386 is_separable = False
387387
388- def transform (self , ll ):
388+ def transform_non_affine (self , ll ):
389389 """
390- Override the transform method to implement the custom transform.
390+ Override the transform_non_affine method to implement the custom
391+ transform.
391392
392393 The input and output are Nx2 numpy arrays.
393394 """
@@ -404,17 +405,32 @@ def transform(self, ll):
404405 y = (sqrt2 * np .sin (latitude )) / alpha
405406 return np .concatenate ((x , y ), 1 )
406407
408+ # Note: For compatibility with matplotlib v1.1 and older, you'll need
409+ # to explicitly implement a ``transform`` method as well. Otherwise a
410+ # ``NotImplementedError`` will be raised. This isn't necessary for v1.2
411+ # and newer, however.
412+ def transform (self , values ):
413+ return self .transform_affine (self .transform_non_affine (values ))
414+ transform .__doc__ = Transform .transform .__doc__
415+
407416 # This is where things get interesting. With this projection,
408417 # straight lines in data space become curves in display space.
409418 # This is done by interpolating new values between the input
410419 # values of the data. Since ``transform`` must not return a
411420 # differently-sized array, any transform that requires
412421 # changing the length of the data array must happen within
413422 # ``transform_path``.
414- def transform_path (self , path ):
415- vertices = path .vertices
423+ def transform_path_non_affine (self , path ):
416424 ipath = path .interpolated (path ._interpolation_steps )
417425 return Path (self .transform (ipath .vertices ), ipath .codes )
426+ transform_path_non_affine .__doc__ = \
427+ Transform .transform_path_non_affine .__doc__
428+
429+ # Once again, for compatibility with matplotlib v1.1 and older, we need
430+ # to explicitly override ``transform_path``. With v1.2 and newer, only
431+ # overriding the ``transform_path_non_affine`` method is sufficient.
432+ transform_path = transform_path_non_affine
433+ transform_path .__doc__ = Transform .transform_path .__doc__
418434
419435 def inverted (self ):
420436 return HammerAxes .InvertedHammerTransform ()
@@ -425,7 +441,7 @@ class InvertedHammerTransform(Transform):
425441 output_dims = 2
426442 is_separable = False
427443
428- def transform (self , xy ):
444+ def transform_non_affine (self , xy ):
429445 x = xy [:, 0 :1 ]
430446 y = xy [:, 1 :2 ]
431447
@@ -435,7 +451,11 @@ def transform(self, xy):
435451 longitude = 2 * np .arctan ((z * x ) / (2.0 * (2.0 * z * z - 1.0 )))
436452 latitude = np .arcsin (y * z )
437453 return np .concatenate ((longitude , latitude ), 1 )
438- transform .__doc__ = Transform .transform .__doc__
454+ transform_non_affine .__doc__ = Transform .transform_non_affine .__doc__
455+
456+ # As before, we need to implement the "transform" method for
457+ # compatibility with matplotlib v1.1 and older.
458+ transform = transform_non_affine
439459
440460 def inverted (self ):
441461 # The inverse of the inverse is the original transform... ;)
0 commit comments