>>>>> "Robert" == Robert Leftwich <ro...@le...> writes:
Robert> I have a requirement to generate a scatter plot with the
Robert> background divided into 4 equal rectangular regions, each
Robert> a different colour/shade indicating a particular
Robert> characteristic of the points in that region. What is the
Robert> 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()
|