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

Skip to content

Commit 9b077f2

Browse files
author
Nathan Goldbaum
committed
Round the output of adjusted_figsize to avoid floating point roundoff error
1 parent 8a77cfb commit 9b077f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/animation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import six
2424
from six.moves import xrange, zip
2525

26+
import numpy as np
2627
import os
2728
import platform
2829
import sys
@@ -62,8 +63,8 @@
6263

6364

6465
def adjusted_figsize(w, h, dpi, n):
65-
wnew = int(w * dpi / n) * n / dpi
66-
hnew = int(h * dpi / n) * n / dpi
66+
wnew = np.round(int(w * dpi / n) * n / dpi)
67+
hnew = np.round(int(h * dpi / n) * n / dpi)
6768
return wnew, hnew
6869

6970

0 commit comments

Comments
 (0)