First time here? Check out the FAQ!

Ask Your Question
0

Strange behavior of plot

asked 5 years ago

Cyrille gravatar image

updated 5 years ago

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
Preview: (hide)

Comments

Before what ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 5 years ago

Juanjo gravatar image

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.

Preview: (hide)
link

Comments

Juanjo many thanks for the explanation.

Cyrille gravatar imageCyrille ( 5 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 747 times

Last updated: Nov 20 '19