Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abcdf28

Browse files
committed
Flip image without modifying attribute when writing PNG
1 parent a4d48d4 commit abcdf28

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/matplotlib/image.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,8 @@ def contains(self, mouseevent):
521521

522522
def write_png(self, fname):
523523
"""Write the image to png file with fname"""
524-
if self.origin == 'upper':
525-
self._A = self._A[::-1]
526-
im = self.to_rgba(self._A, bytes=True, norm=True)
524+
im = self.to_rgba(self._A[::-1] if self.origin == 'upper' else self._A,
525+
bytes=True, norm=True)
527526
_png.write_png(im, fname)
528527

529528
def set_data(self, A):

0 commit comments

Comments
 (0)