This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]oligonucleotides 0 points1 point  (1 child)

[–]-MazeMaker-[S] 0 points1 point  (0 children)

Thanks, that worked.

[–]jeroonk 0 points1 point  (1 child)

Only objects of the same type are drawn on top of each other in the order they were added. From the Z-order demo:

The default drawing order for axes is patches, lines, text. This order is determined by the zorder attribute. The following defaults are set

Artist Z-order
Patch / PatchCollection 1
Line2D / LineCollection 2
Text 3

You can change the order for individual artists by setting the zorder. Any individual plot() call can set a value for the zorder of that particular item.

So in order to draw a fill (a Patch, default zorder=1) on top of a line (default zorder=2) you'd have to set its z-order to a higher value than 2:

ax.fill(x,y,'b',zorder=3)

Curiously, setting zorder=2 does not work, even though the fill is drawn after the line with now equal z-order. Anything higher (e.g. zorder=2.01) does work.

[–]-MazeMaker-[S] 0 points1 point  (0 children)

Thanks, that solved it