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

Skip to content

Commit 599500c

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
2 parents 64384a3 + 99d5012 commit 599500c

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

lib/matplotlib/backends/backend_qt4agg.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ def __init__(self, figure):
7272
self.rect = []
7373
self.blitbox = None
7474
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
75+
# it has been reported that Qt is semi-broken in a windows
76+
# environment. If `self.draw()` uses `update` to trigger a
77+
# system-level window repaint (as is explicitly advised in the
78+
# Qt documentation) the figure responds very slowly to mouse
79+
# input. The work around is to directly use `repaint`
80+
# (against the advice of the Qt documentation). The
81+
# difference between `update` and repaint is that `update`
82+
# schedules a `repaint` for the next time the system is idle,
83+
# where as `repaint` repaints the window immediately. The
84+
# risk is if `self.draw` gets called with in another `repaint`
85+
# method there will be an infinite recursion. Thus, we only
86+
# expose windows users to this risk.
87+
if sys.platform.startswith('win'):
88+
self._priv_update = self.repaint
89+
else:
90+
self._priv_update = self.update
7591

7692
def drawRectangle(self, rect):
7793
self.rect = rect
@@ -154,7 +170,7 @@ def draw(self):
154170
# causes problems with code that uses the result of the
155171
# draw() to update plot elements.
156172
FigureCanvasAgg.draw(self)
157-
self.update()
173+
self._priv_update()
158174

159175
def blit(self, bbox=None):
160176
"""

lib/matplotlib/figure.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ def set_size_inches(self, *args, **kwargs):
641641
"""
642642
set_size_inches(w,h, forward=False)
643643
644-
Set the figure size in inches
644+
Set the figure size in inches (1in == 2.54cm)
645645
646646
Usage::
647647
@@ -653,6 +653,11 @@ def set_size_inches(self, *args, **kwargs):
653653
from the shell
654654
655655
ACCEPTS: a w,h tuple with w,h in inches
656+
657+
See Also
658+
--------
659+
660+
:func:`~matplotlib.Figure.get_size_inches`
656661
"""
657662

658663
forward = kwargs.get('forward', False)
@@ -673,7 +678,21 @@ def set_size_inches(self, *args, **kwargs):
673678
manager.resize(int(canvasw), int(canvash))
674679

675680
def get_size_inches(self):
676-
return self.bbox_inches.p1
681+
"""
682+
Returns the current size of the figure in inches (1in == 2.54cm)
683+
as an numpy array.
684+
685+
Returns
686+
-------
687+
size : ndarray
688+
The size of the figure in inches
689+
690+
See Also
691+
--------
692+
693+
:func:`~matplotlib.Figure.set_size_inches`
694+
"""
695+
return np.array(self.bbox_inches.p1)
677696

678697
def get_edgecolor(self):
679698
'Get the edge color of the Figure rectangle'

0 commit comments

Comments
 (0)