Your two triangles with points (0, 0), (10, 0), (10, 0.5) and (0, 0), (1, 0), (0.5, 11) will be represented in pylab as:
Ax = [0, 10, 10] Ay = [0, 0, 0.5] Bx = [0, 1, 0.5] By = [0, 0, 11] pylab.plot(Ax, Ay) pylab.plot(Bx, By)
Let's see what the lowest value of X is:
lowestX = None for x in Ax+Bx: if lowestX==None or x<lowestX: lowestX = x
An exercise for the reader to do the same for highestX , lowestY and highestY .
Now consider the border of 2 units, you can add / subtract these units from the lowest and highest values โโand set xlim and ylim :
margin = 2 pylab.xlim([lowestX-margin, highestX+margin]) pylab.ylim([lowestY-margin, highestY+margin])
source share