Coloured background regions?

I have a requirement to generate a scatter plot with the

    > background divided into 4 equal rectangular regions, each
    > a different colour/shade indicating a particular
    > characteristic of the points in that region. What is the
    > best way to do this in matplotlib?

Below is a script that shows one way to do it. If you don't like the
black border surrounding the different colored quadrants, you can set
the "edgecolor" property to be the same as the "facecolor"

Is this what you are looking for?
JDH

from pylab import *

# lower left quadrant
r1 = Rectangle( (0.0, 0.0), 5, 5, facecolor='yellow')

# lower right quadrant
r2 = Rectangle( (5.0, 0.0), 5, 5, facecolor='red')

# upper left quadrant
r3 = Rectangle( (0.0, 5.0), 5, 5, facecolor='blue')

# upper right quadrant
r4 = Rectangle( (5.0, 5.0), 5, 5, facecolor='green')

ax = subplot(111)
for r in (r1,r2,r3,r4):
    ax.add_patch(r)

scatter(10*rand(100), 10*rand(100))
axis([0, 10, 0, 10])
show()

John Hunter wrote:

Below is a script that shows one way to do it....

Is this what you are looking for?

Yep, although I wasn't expecting someone to write the script for me! A simple - check out the Rectangle command would have sufficed - which, incidentally is exactly what I was reading in the user manual when your email came in :slight_smile:

Much appreciated.

Robert