1

I'm looking for a way to force a given part of the image to background without having to also change the rest of the parts that compose that image.

Example: I have an image made of a grid, a few lines, a histogram and some scatter points. Even though I'm drawing the grid first, it shows above everything else in the image.

This is the line I use to set the grid:

ax.grid(b=True, which='major', color='gray', linestyle='--', lw=1)

I know I can give the grid a zorder value of say 1 and higher zorders for the rest of the parts that make up the image, but I have lots of images with lots of grids and other parts. It'd be much easier if I could just give a zorder to the grid to force it to draw last than having to also edit all the lines, points, etc.

Gabriel
  • 40,504
  • 73
  • 230
  • 404
  • 2
    Actually, the grid has a lower z-order by default. The exact opposite of what you're seeing will happen by default. Can you show an example of what you're doing? (Otherwise, you can use negative numbers for `zorder`.) – Joe Kington Dec 04 '13 at 00:27
  • I tried setting `zorder=-1` but it didn't work. @bernie is right, the answer in that question solved it. Should I vote to close this question? – Gabriel Dec 04 '13 at 01:43
  • @Gabriel - Ah! I misunderstood what you meant by "grid"... I thought you meant a grid displayed with `imshow`, `pcolor`, etc. Obviously, you meant the actual grid on the axes. You can close the question or not, up to you, but it does appear to be a duplicate, as you mentioned. – Joe Kington Dec 04 '13 at 02:04
  • This is the grid I mean: `ax.grid(b=True, which='major', color='gray', linestyle='--', lw=1)`. I'll add this to the question just for the sake of completeness and vote to close it. Thanks! – Gabriel Dec 04 '13 at 02:06

0 Answers0