Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If I understand what you want to do, you would have to have some keyword in order to do this anyway. I suppose you would want something like

sage: G = Graphics()
sage: L = [list of graphics objects you want to add to G]
sage: for g in L:
....:     current_max_zorder = G.get_max_zorder()
....:     G += g[0].set_zorder(current_max_zorder+1)

Or something similar if you have one graphics object with many primitives that you want to add one at a time. The problem is of course getting current_max_zorder. Here is one way you might do that.

sage: G = plot(sin)+circle((3,2),2)+arrow((5,6),(3,2))
sage: current_max_zorder=0
sage: for g in G:   
....:     current_max_zorder=max(current_max_zorder,g.options().get('zorder',current_max_zorder))
sage: current_max_zorder
5

You need this because most graphics objects do not acquire a zorder immediately, though some do in their options decorator. (That is something that could eventually be unified...)

If you think that this is useful enough for everyone, we could open a ticket for making it easier.