On 10/27/06, Robert Miller <[EMAIL PROTECTED]> wrote:
There's one thing that the Graphics class needs: the way it's written
right now, the only graphics primitives you can add are the ones
listed in the module itself. If I get to the following point,

import networkx as NX
G = NX.dodecahedral_graph()
N = GraphicPrimitive_NetworkXGraph(G)

If the above code is how a user would it you, I dont think thats
right because (as of now) the GraphicPrimitive_* are not public classes.

(where GraphicPrimitive_NetworkXGraph is defined to extend the
GraphicPrimitive class), the only way to get this primitive into a
Graphics object (at least the only way I see) is with a hack such as
the following:

g = circle((0,0),1)
g[0]=N.

When I do this, g.show() will display the graph, but this seems
insatisfactory. I propose the following patch to the Graphics class:

def append(self, other):
    if isinstance(other, int) and other == 0:
        return self
    elif isinstance(other, GraphicPrimitive):
        self.__objects += [other]
    elif isinstance(other, Graphics):
        self += other
    else:
        raise TypeError

This brings up a good point, which is basically that the SAGE graphics class
does not accept matplotlib primitives (from a users point of view).

I think a general fix to all this is to do something like:

def append(self, other):
    if isinstance(other, int) and other == 0:
        return self
    elif isinstance(other, Graphics_matplotlib):
        self.__objects += [other]
    elif isinstance(other, Graphics):
        self += other
    else:
        raise TypeError

( we will have to figure out the details of the type Graphics_matplotlib)
but then the SAGE graphics will accept all matplotlib graphics primitives too.
( like the ones returned by networkX or pylab or anything else built on matplotlib)

-Alex

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to