diralik Asked:2020-11-11 00:57:17 +0000 UTC2020-11-11 00:57:17 +0000 UTC 2020-11-11 00:57:17 +0000 UTC 设置使用 matplotlib 获得的窗口坐标 772 我的程序使用 matplotlib 在屏幕上显示绘图。在这种情况下,如何使用出现的图形设置窗口的坐标? 我画这样的图表: import matplotlib.pyplot as plt plt.figure() plt.plot([1, 2, 3], [2, 4, 8]) plt.show() python 1 个回答 Voted Best Answer diralik 2020-11-11T00:57:17Z2020-11-11T00:57:17Z 答案因使用的后端而异。在所有示例中,您需要替换所需的窗口绝对坐标,而不是xand 。y TkAgg: plt.get_current_fig_manager().window.wm_geometry('+x+y') WXAgg: plt.get_current_fig_manager().window.SetPosition((x, y)) 数量: plt.get_current_fig_manager().window.move(x, y) 或者,之前已经获得了窗口的高度和宽度: # x_old и y_old --- старые координаты окна, их значения не используются x_old, y_old, width, height = plt.get_current_fig_manager().window.geometry().getRect() plt.get_current_fig_manager().window.setGeometry(x, y, width, height)
答案因使用的后端而异。在所有示例中,您需要替换所需的窗口绝对坐标,而不是
xand 。yTkAgg:
WXAgg:
数量:
或者,之前已经获得了窗口的高度和宽度: