本文整理汇总了Python中matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg.manager方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.manager方法的具体用法?Python FigureCanvasQTAgg.manager怎么用?Python FigureCanvasQTAgg.manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.manager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resize_qt
# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import manager [as 别名]
def test_resize_qt():
# This test just ensures that the code runs, but doesn't check for now
# that the behavior is correct.
pytest.importorskip('PyQt5')
from PyQt5.QtWidgets import QMainWindow
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5 import FigureManagerQT
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
fig = Figure()
canvas = FigureCanvasQTAgg(fig)
canvas.manager = FigureManagerQT(canvas, 0) # noqa
ax = fig.add_subplot(1, 1, 1)
canvas.draw = Mock(side_effect=canvas.draw)
from matplotlib.backends.backend_qt5 import qApp
window = QMainWindow()
window.setCentralWidget(canvas)
window.show()
x1 = np.random.normal(0, 1, 10000000)
y1 = np.random.normal(0, 1, 10000000)
a = ScatterDensityArtist(ax, x1, y1)
ax.add_artist(a)
canvas.draw()
assert not a.stale
assert canvas.draw.call_count == 1
window.resize(300, 300)
# We can't actually check that stale is set to True since it only remains
# so for a short amount of time, but we can check that draw is called twice
# (once at the original resolution then once with the updated resolution).
start = time.time()
while time.time() - start < 1:
qApp.processEvents()
assert canvas.draw.call_count == 3
assert not a.stale
start = time.time()
while time.time() - start < 1:
qApp.processEvents()
a.remove()
qApp.processEvents()