What is zorder?

QuestionsQuestions8 SkillsProMatplotlib Scatter PlotsOct, 03 2025
0163

zorder is an attribute in Matplotlib that determines the drawing order of plot elements (artists). It is a floating-point number, and artists with higher zorder values are drawn on top of those with lower values.

For example:

  • Images typically have a default zorder of 0.
  • Patches (like rectangles or circles) have a default zorder of 1.
  • Lines and markers can have higher zorder values assigned to them.

By adjusting the zorder, you can control which elements appear in front or behind others in your plots. This is particularly useful when you want to overlay elements, such as adding a grid behind a line plot or placing annotations above other plot elements.

0 Comments

no data
Be the first to share your comment!