Creating custom rectangle

I'm looking to create a type of rectangle that draws with a cross from corner
to corner, all as a single class type. To do this, I've created a subtype of
the rectange class, that records what the current axis is and tries to draw
two lines to it in the draw function. When displayting the graph, initially
the cross is not shown, but if I zoom/pan the graph, the cross appears. Can
anyone see where my problem lies and possibly present a solution?


from matplotlib.lines import Line2D
from matplotlib.patches import Rectangle
from pylab import figure, show

class CrossRect(Rectangle):
    def __init__(self, ax, *args, **kwargs):
        Rectangle.__init__(self, *args, **kwargs) = ax

    def draw(self, renderer):
        Rectangle.draw(self, renderer)

    def _draw_cross(self):

        forward_slash=Line2D((x, x+self.get_width()), (y,
        back_slash=Line2D((x, x+self.get_width()), (y+self.get_height(), y))

fig = figure()
ax = fig.add_subplot(111, autoscale_on=True)

left, width, bottom, height = 5, 5, 5, 5
rect = CrossRect(ax, (left, bottom), width, height, fill=False)



View this message in context:
Sent from the matplotlib - users mailing list archive at