Ask Your Question
0

Strange behavior of plot

asked 2019-11-20 19:10:05 +0200

Cyrille gravatar image

updated 2019-11-20 19:28:18 +0200

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 flag offensive close merge delete

Comments

Before what ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-11-20 19:50:08 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-11-20 22:44:00 +0200

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.

edit flag offensive delete link more

Comments

Juanjo many thanks for the explanation.

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

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: 2019-11-20 19:10:05 +0200

Seen: 323 times

Last updated: Nov 20 '19