Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixed large pcolormesh rendering with bbox_inches='tight'.#4045

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 1 commit intomatplotlib:v1.4.xfrompelson:quadmesh_big
Jan 31, 2015

Conversation

pelson
Copy link
Member

Replaces#4017.
Closes#3095.

@pelsonpelson mentioned this pull requestJan 28, 2015
@pelsonpelson added this to thev1.4.3 milestoneJan 28, 2015
@tacaswell
Copy link
Member

This does not account for having a non-trivialoffset array.

@pelson
Copy link
MemberAuthor

This does not account for having a non-trivial offset array.

Can you provide a simple example? I've never properly understood the offsets in some collection contexts.

@tacaswell
Copy link
Member

importnumpyasnpimportmatplotlib.pyplotaspltfig,ax=plt.subplots(1,1)X,Y=np.meshgrid(range(25),range(20))C=np.random.rand(*X.shape)offsets= (np.random.randn(2,24*19)ax.pcolormesh(X,Y,C,offsets=offsets,transOffset=ax.transData)

so

which has an odd extra shift from (0, 0) to (3, 2.3) for the lower left. I am also notreally clear on why this is useful, but it is something that the code does.

@tacaswell
Copy link
Member

The code for this in agg ends up in c++ layer and gets really hairy really fast.

@tacaswell
Copy link
Member

importnumpyasnpimportmatplotlib.pyplotaspltfig,ax=plt.subplots(1,1)X,Y=np.meshgrid(range(25),range(20))C=np.random.rand(*X.shape)offsets=np.random.randn(24*19,2)*.1ax.pcolormesh(X,Y,C)#, offsets=offsets, transOffset=ax.transData)fig.savefig('so.png',bbox_inches='tight')

gives me

<ipython-input-26-382f89238547> in <module>()----> 1 exec(compile(open('/tmp/ipython-5366aRU.py').read(), '/tmp/ipython-5366aRU.py', 'exec')) # PYTHON-MODE/tmp/ipython-5366aRU.py in <module>()/home/tcaswell/.virtualenvs/mpl_master_3k/lib/python2.7/site-packages/matplotlib-1.4.x.dev0-py2.7-linux-x86_64.egg/matplotlib/figure.pyc in savefig(self, *args, **kwargs)   1474             self.set_frameon(frameon)   1475 -> 1476         self.canvas.print_figure(*args, **kwargs)   1477    1478         if frameon:/home/tcaswell/.virtualenvs/mpl_master_3k/lib/python2.7/site-packages/matplotlib-1.4.x.dev0-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt5agg.pyc in print_figure(self, *args, **kwargs)    159     160     def print_figure(self, *args, **kwargs):--> 161         FigureCanvasAgg.print_figure(self, *args, **kwargs)    162         self.draw()    163 /home/tcaswell/.virtualenvs/mpl_master_3k/lib/python2.7/site-packages/matplotlib-1.4.x.dev0-py2.7-linux-x86_64.egg/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)   2166                 bbox_filtered = []   2167                 for a in bbox_artists:-> 2168                     bbox = a.get_window_extent(renderer)   2169                     if a.get_clip_on():   2170                         clip_box = a.get_clip_box()/home/tcaswell/.virtualenvs/mpl_master_3k/lib/python2.7/site-packages/matplotlib-1.4.x.dev0-py2.7-linux-x86_64.egg/matplotlib/collections.pyc in get_window_extent(self, renderer)    208         # TODO:check to ensure that this does not fail for    209         # cases other than scatter plot legend--> 210         return self.get_datalim(transforms.IdentityTransform())    211     212     def _prepare_points(self):/home/tcaswell/.virtualenvs/mpl_master_3k/lib/python2.7/site-packages/matplotlib-1.4.x.dev0-py2.7-linux-x86_64.egg/matplotlib/collections.pyc in get_datalim(self, transData)   1707    1708     def get_datalim(self, transData):-> 1709         return (self.get_transform() - transData).transform_bbox(self._bbox)   1710    1711     @staticmethod/home/tcaswell/.virtualenvs/mpl_master_3k/lib/python2.7/site-packages/matplotlib-1.4.x.dev0-py2.7-linux-x86_64.egg/matplotlib/transforms.pyc in transform_bbox(self, bbox)   1352         requirement for matplotlib figures), see :class:`TransformedBbox`.   1353         """-> 1354         return Bbox(self._transform.transform(bbox.get_points()))   1355    1356     def get_affine(self):AttributeError: 'CompositeGenericTransform' object has no attribute '_transform'

Note, for smarter transforms including caching (a common
requirement for matplotlib figures), see :class:`TransformedBbox`.
"""
return Bbox(self._transform.transform(bbox.get_points()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this line should bereturn Bbox(self..transform(bbox.get_points()))

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agreed.

@pelson
Copy link
MemberAuthor

Thanks for the example@tacaswell. I did not know you could do that!
I'll take a look at dealing with the offsets, but ultimately if this is holding up a release, I'd be comfortable trading a major performance bug with pcolormesh, for a minor cut-off known bug with a not-well-used part of the same routine.

@tacaswell
Copy link
Member

I concur about the trade off.

@tacaswelltacaswell added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelJan 31, 2015
@tacaswelltacaswell merged commit44ff97e intomatplotlib:v1.4.xJan 31, 2015
tacaswell added a commit that referenced this pull requestJan 31, 2015
BUG : Fix run-away memory usage with pcolormesh + bbox_inches='tight'
@pelsonpelson deleted the quadmesh_big branchFebruary 1, 2015 22:54
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v1.4.3
Development

Successfully merging this pull request may close these issues.

2 participants
@pelson@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp