"plot" plots too many markers when projection="hammer" is used.

Hi,

While playing a little bit with "custom_projection_example.py", I
found that "plot" command with projection="hammer" plots too many
markers.

For example,

    subplot(111, projection="hammer")
    grid(True)
    p = plot([-1, 1, 1], [-1, -1, 1], "o")
    show()

plots more than 100 circles, instead of 3. And I presume that this is
a bug not a feature.
This seems to be because the draw() method of the Line2D class uses
self._transformed_path for plotting Markers, but number of vertices
in the _transformed_path increases in the curved coordinate system as
in the example.

A patch to fix this is attached. It defines a new property
"self._transformed_path_mark" in the recache() method as follows

        tr = self.get_transform()
        self._transformed_path = TransformedPath(self._path, tr)
        self._transformed_path_mark =
Path(tr.transform_non_affine(self._path.vertices))

and draw() method uses this for plotting markers.

                tpath, affine = self._transformed_path_mark, \
                                self.get_transform().get_affine()

As I'm not 100% sure about how the transform things work, I may have
missed something. But I got correct results for cases I tried.
So I hope this patch is reviewed and applied.

Regards,

-JJ

I forgot to attach the patch.

-JJ

mpl_line2d.patch (1.11 KB)

···

On Fri, Jul 25, 2008 at 2:39 AM, Jae-Joon Lee <lee.j.joon@...149...> wrote:

Hi,

While playing a little bit with "custom_projection_example.py", I
found that "plot" command with projection="hammer" plots too many
markers.

For example,

   subplot(111, projection="hammer")
   grid(True)
   p = plot([-1, 1, 1], [-1, -1, 1], "o")
   show()

plots more than 100 circles, instead of 3. And I presume that this is
a bug not a feature.
This seems to be because the draw() method of the Line2D class uses
self._transformed_path for plotting Markers, but number of vertices
in the _transformed_path increases in the curved coordinate system as
in the example.

A patch to fix this is attached. It defines a new property
"self._transformed_path_mark" in the recache() method as follows

       tr = self.get_transform()
       self._transformed_path = TransformedPath(self._path, tr)
       self._transformed_path_mark =
Path(tr.transform_non_affine(self._path.vertices))

and draw() method uses this for plotting markers.

               tpath, affine = self._transformed_path_mark, \
                               self.get_transform().get_affine()

As I'm not 100% sure about how the transform things work, I may have
missed something. But I got correct results for cases I tried.
So I hope this patch is reviewed and applied.

Regards,

-JJ

What's happening here is that the Hammer projection uses interpolation to make the lines follow the curve of the projection. Obviously with markers, we don't want that interpolation. The fix is to just use transform_points rather than transform_path with markers. This is now fixed in SVN r5934.

Cheers,
Mike

Jae-Joon Lee wrote:

···

I forgot to attach the patch.

-JJ

On Fri, Jul 25, 2008 at 2:39 AM, Jae-Joon Lee <lee.j.joon@...149...> wrote:
  

Hi,

While playing a little bit with "custom_projection_example.py", I
found that "plot" command with projection="hammer" plots too many
markers.

For example,

   subplot(111, projection="hammer")
   grid(True)
   p = plot([-1, 1, 1], [-1, -1, 1], "o")
   show()

plots more than 100 circles, instead of 3. And I presume that this is
a bug not a feature.
This seems to be because the draw() method of the Line2D class uses
self._transformed_path for plotting Markers, but number of vertices
in the _transformed_path increases in the curved coordinate system as
in the example.

A patch to fix this is attached. It defines a new property
"self._transformed_path_mark" in the recache() method as follows

       tr = self.get_transform()
       self._transformed_path = TransformedPath(self._path, tr)
       self._transformed_path_mark =
Path(tr.transform_non_affine(self._path.vertices))

and draw() method uses this for plotting markers.

               tpath, affine = self._transformed_path_mark, \
                               self.get_transform().get_affine()

As I'm not 100% sure about how the transform things work, I may have
missed something. But I got correct results for cases I tried.
So I hope this patch is reviewed and applied.

Regards,

-JJ

    ------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
    
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA