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
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
···
On Thursday, September 6, 2012, jonasr wrote:
Hello,
i spotted a bug in the Rectangle function when plotting with multiple
I would have thought that the add_patch function creates two seperate
objects independent of the defined Rectangle.
add_patch doesn't create any objects; it just attaches the axes to the patch in both directions: a reference to the patch object is appended to a list of axes artists, and the patch object gets a reference to the axes. Fortunately, python has garbage collection to handle such circular references.
I guess in future, we could add a check to the add_patch method to see if the given artist already has an associated Axes, and if it does, emit a warning.
···
On 7 September 2012 07:42, Eric Firing <efiring@…202…> wrote:
On 2012/09/06 8:35 PM, jonasr wrote:
That seems to work, thank you.
I would have thought that the add_patch function creates two seperate
objects independent of the defined Rectangle.
add_patch doesn’t create any objects; it just attaches the axes to the
patch in both directions: a reference to the patch object is appended to
a list of axes artists, and the patch object gets a reference to the
axes. Fortunately, python has garbage collection to handle such
circular references.
Eric
greets jonas
Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
I guess in future, we could add a check to the add_patch method to see
if the given artist already has an associated Axes, and if it does, emit
a warning.
It's not just patches; but I think a single warning in Artist.add_axes would do it, perhaps at the cost of generating an unnecessary warning for some legitimate use case.
Eric
···
On 2012/09/06 9:03 PM, Phil Elson wrote:
On 7 September 2012 07:42, Eric Firing <efiring@…202… > <mailto:efiring@…202…>> wrote:
On 2012/09/06 8:35 PM, jonasr wrote:
> That seems to work, thank you.
>
> I would have thought that the add_patch function creates two seperate
> objects independent of the defined Rectangle.
add_patch doesn't create any objects; it just attaches the axes to the
patch in both directions: a reference to the patch object is appended to
a list of axes artists, and the patch object gets a reference to the
axes. Fortunately, python has garbage collection to handle such
circular references.