FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

_update_patch_transform(): AttributeError: 'Rectangle' object has no attribute '_y' · Issue #2268 · matplotlib/matplotlib · GitHub

Repository navigation

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

Closed

Description

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'

Activity

  1. mdboom commented on Aug 1, 2013

    Member

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

  2. mmokrejs commented on Aug 1, 2013

    Author

    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.

  3. mdboom commented on Aug 1, 2013

    Member

    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.

  4. efiring commented on Aug 10, 2013

    Member

    @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.

  5. tacaswell commented on Jun 29, 2014

    Member

    Not clear and no communications in 10mo, closing.

  6. joker-wutong commented on 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???

  7. efiring commented on Apr 1, 2020

    Member

    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.

  8. joker-wutong commented on Apr 1, 2020

  9. joker-wutong commented on 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()
  10. story645 commented on Apr 8, 2020

    Member

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL