Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_update_patch_transform(): AttributeError: 'Rectangle' object has no attribute '_y' #2268

Closed
mmokrejs opened this issue Aug 1, 2013 · 10 comments

Comments

@mmokrejs
Copy link

mmokrejs commented Aug 1, 2013

Hi,
I have another case where matplotlib-1.2.1 crashes somewhere deeply.

...
draw_hist_plot('somefile.png', _mydata, _colors, _title, _xlabel, _ylabel, _legends, legend_loc=_legend_loc, legend_bbox_to_anchor=_legend_bbox_to_anchor, ymin=0, fontsize=10, dpi=100, bin_count=_bin_count)
File "myprogram.py", line 11881, in draw_hist_plot
_figure.savefig(filename, dpi=100)
File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1370, in savefig
self.canvas.print_figure(_args, *_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 2096, in print_figure
*_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 492, in print_png
FigureCanvasAgg.draw(self)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 440, in draw
self.figure.draw(self.renderer)
File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, *_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1006, in draw
func(_args)
File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, *_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/axes.py", line 2086, in draw
a.draw(renderer)
File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 54, in draw_wrapper
draw(artist, renderer, _args, *_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/patches.py", line 433, in draw
transform = self.get_transform()
File "/usr/lib64/python2.7/site-packages/matplotlib/patches.py", line 176, in get_transform
return self.get_patch_transform() + artist.Artist.get_transform(self)
File "/usr/lib64/python2.7/site-packages/matplotlib/patches.py", line 581, in get_patch_transform
self._update_patch_transform()
File "/usr/lib64/python2.7/site-packages/matplotlib/patches.py", line 574, in _update_patch_transform
y = self.convert_yunits(self._y)
AttributeError: 'Rectangle' object has no attribute '_y'

@mdboom
Copy link
Member

mdboom commented Aug 1, 2013

Do you have a simple, self-contained example that reproduces the bug?

@mmokrejs
Copy link
Author

mmokrejs commented Aug 1, 2013

Unfortunately not, I hope you can handcraft something as you know what is the code doing. If not, please let me know and I will try to find some time, but am not very optimistic.

@mdboom
Copy link
Member

mdboom commented Aug 1, 2013

The problem is, I don't know what your code is doing to cause this, so I would have to go hunting to reproduce this error (which our test suite obviously doesn't find).

http://sscce.org/ may explain better what I'm getting at.

@efiring
Copy link
Member

efiring commented Aug 10, 2013

@mmokrejs, it is hard to see how this error could occur in normal use. The _x and _y attributes of the Rectangle are created upon initialization. The traceback indicates that the _x attribute is still there, but the _y attribute has somehow disappeared.

If you can run inside of ipython, you could use %debug for post-mortem debugging to find out where your Rectangle object came from, and whether it is missing any other attributes.

@tacaswell
Copy link
Member

Not clear and no communications in 10mo, closing.

@joker-wutong
Copy link

joker-wutong commented Apr 1, 2020

I have this question:AttributeError: 'Rectangle' object has no property 'normed'
The code is :
import random
import matplotlib.pyplot as plt

#解决中文显示问题
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

def roll_dice():
"""
模拟掷骰子

"""
roll = random.randint(1,6)
return roll

def main():
total_times = 10

#记录骰子的结果
roll_list = []

for i in range(total_times):
    roll1 = roll_dice()
    roll2 = roll_dice()

    roll_list.append(roll1 + roll2)

#数据可视化
plt.hist(roll_list,bins = range(2,14,1),normed = 1,edgecolor = 'green',linewidth = 1)
plt.title('骰子点数统计')
plt.xlabel('点数')
plt.ylabel('频率')
plt.show()

if name=='main':
main()

so, what measures should i do to solve this problem???

@efiring
Copy link
Member

efiring commented Apr 1, 2020

The "normed" kwarg has been removed recently for consistency with np.histogram. Use density=True instead.
In the future, please ask questions like this on the matplotlib-users mailing list or stackoverflow, and use an SSCCE (http://sscce.org/) to illustrate--strip it down to the bare minimum. Also specify the matplotlib version.

@joker-wutong
Copy link

joker-wutong commented Apr 1, 2020 via email

@joker-wutong
Copy link

joker-wutong commented Apr 8, 2020

my matplotlib version 2.1.0
I have a case :
AttributeError: 'Rectangle' object has no property 'normed'

The cord is:

import random
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
def roll_dice():
    roll = random.randint(1,6)
    return roll
def main():
    total_times = 10
    roll_list = []
    for i in range(total_times):
        roll1 = roll_dice()
        roll2 = roll_dice()
        roll_list.append(roll1 + roll2)
    plt.hist(roll_list,bins = range(2,14,1),normed = 1,edgecolor = 'green',linewidth = 1)
    plt.title('骰子点数统计')
    plt.xlabel('点数')
    plt.ylabel('频率')
    plt.show()

if __name__=='__main__':
    main()

@story645
Copy link
Member

story645 commented Apr 8, 2020

@joker-wutong there's no normed keyword argument to plt.hist. It was deprecated a while back, and now the density flag is a close analogue.
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html?highlight=hist#matplotlib.pyplot.hist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants