plotting directly using the renderer

Hello everyone, Hello John,

    > as you advised in a Mail some days ago concerning a
    > fastplot-command I wrote a polygon_factory and it worked
    > quite well (In large parts taken from Line2D). See the
    > code attached. What I now want to ask you is: Would it be
    > good to write this object-oriented (propably yes, so one
    > gets rid of all those tiny funktions _make_...(size))? One
    > drawback which comes into my mind is: How should this
    > class be used within fastplot()? Initialize an instance
    > each time you plot a single point? Wouldn't this slow down
    > everything a bit (or am I overestimating the time-scales)?
    > On the otherhand using a class would look very 'tidy'.

Yes, it would be tidy, but you might pay for that in performance as
you suggest. As far as tidiness, you can use the existing approach
and not add all the _make* functions the __all__ list the module
exports -- this would make the helper functions invisible. You could
also use nested scopes

def my_factory(*args):
    def helper1(x): pass
    def helper2(x): pass

However, since the code you use to compute the vertices is lifted from, it would be nice to define one set of functions that could
be reused by both the line marker code and polygon code. This would
be the cleanest design and would be easier to maintain, but it would
require refactoring both your code and the code a little. If
you want to take this on, that would be great.


Hi John, Martin,

I was experimenting with drawing markers one at a time for a ReadCursor
class to provide the option of marking the position of the cursor. I saw this
email and read the thread (the users mailing list is very helpful).

Since markers and lines go together and implementing markers in the same way
for ReadCursor would cause a lot of code duplication, I tried pulling out the relevant
functions from and creating a Marker class - attached. A test function is below.
  I am using TkAgg, so _newstyle is True and renderer has draw_markers.
x and y in Marker.__init__ are sequences and are turned into 1d arrays before passed to
draw_markers. I get:

Traceback (most recent call last):
   File "", line 9, in ?
   File "/Users/dencheva/cvs-matplotlib/matplotlib/lib/matplotlib/", line 556, in draw_marker
     markerFunc(renderer, gc, xt, yt)
   File "/Users/dencheva/cvs-matplotlib/matplotlib/lib/matplotlib/", line 85, in _draw_pixel
     renderer.draw_markers(gc, path, xt, yt)
IndexError: Unexpected SeqBase<T> length.

What am I doing wrong?

If I set _newstyle explicitely to False, in order to test this part of the various draw_* functions,
I don't get any errors but a marker is not plotted.
So, again I must be doing something wrong.

If I understand this correctly I need the same functionality as Martin. If either of you have any ideas of
what is wrong, I'd appreciate any help. Also we don't have to reinvent the wheel independently, so if
this is not the right approach and Martin has a better way I am willing to help with this, by testing or any
other way.

Nadia Dencheva (161 Bytes) (19.6 KB)