|
From: Benjamin R. <ben...@ou...> - 2012-09-07 03:57:34
|
On Thursday, September 6, 2012, jonasr wrote: > Hello, > > i spotted a bug in the Rectangle function when plotting with multiple > subplot, here is a source code example: > > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > from matplotlib.pyplot import * > from numpy import * > import sys, os > > def main(): > f, axs = subplots(1,2) > > x=arange(0,10,0.001) > y=sin(x) > axs[0].plot(x,y,"blue")#,alpha=1) > axs[1].plot(x,y,"blue",alpha=1) > > rect = Rectangle((0,0), 1, 1, facecolor="blue",alpha=1) > axs[0].add_patch(rect) > axs[1].add_patch(rect) > > show() > return 0 > > if __name__ == '__main__': > main() > > this script should plot two sin functions and a rectangle in both subplots > . > the rectangle doesn't seem to appear until i move the area from the left > subplot (where the rectangle should appear) > over to the second subplot. > here is an example how it looks like: > http://www.imagebanana.com/view/hzm8bjro/example.png > > if i remove the command > axs[1].add_patch(rect) > the problem doesn't seem to appear > > my current matplotlib version is: '1.1.1rc' > os is ubuntu 12.04 > > greetz jonas > > > > Not a bug. An artist, such as the rectangle patch, can only reliably work in one axes object at a time. It can not be in two places at once. Make two rectangles and attach each to an axes, and it will work. Cheers! Ben Root |