# Strange behavior of plot

In the following graphic, I woul like to understand why the line which is called after the the second circle is drawn before

from sage.plot.circle import Circle
c1= circle((1,1), 1, fill=true, color='blue', alpha=0.1)
c2= circle((1,1), .85, fill=true,  color='white', alpha=0.8)
center= circle((1,1), .0125, fill=true,  color='black')
p1= circle((0.2,1.5), .0125, fill=true,  color='red')
p2= circle((0.7,1.8), .0125, fill=true,  color='red')
p3= circle((1.7,1.6), .0125, fill=true,  color='red')
p4= circle((2,1), .0125, fill=true,  color='red')
l= line([(0,1), (1,1),(1,0)],linestyle="--")
c1+c2+center+p1+p2+p3+p4+l
edit retag close merge delete

Before what ?

( 2019-11-20 19:50:08 +0200 )edit

Sort by ยป oldest newest most voted

I assume that you want the line to be drawn on the circles. You can simply achieve that if you add zorder=n, with n greater than or equal to 5, as an option of line, i.e

l = line([(0,1), (1,1),(1,0)], linestyle="--", zorder=5)

The problem is that zorder has no default value for the line, but it has been set to 5 for the circles. Hence, the line is not drawn in the right layer, even if it appears as the last object added to the figure. We can see this as follows. First, the zorder for the circles:

sage: [c[0].options()['zorder']  for c in [c1, c2, center, p1, p2, p3, p4]]
[5, 5, 5, 5, 5, 5, 5]

However,

sage: l[0].options()['zorder']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-14-075edb4cde49> in <module>()
----> 1 l[Integer(0)].options()['zorder']
KeyError: 'zorder'

By the way, I would not use l as a variable, since it can be easily confused with 1.

more

Juanjo many thanks for the explanation.

( 2019-11-21 09:31:01 +0200 )edit