如何修改/固定matplotlib显示图片窗口在屏幕上的位置 |
您所在的位置:网站首页 › qq中心在那个位置显示 › 如何修改/固定matplotlib显示图片窗口在屏幕上的位置 |
参考:https://stackoverflow.com/questions/7449585/how-do-you-set-the-absolute-position-of-figure-windows-with-matplotlib matplotlib默认使用TkAgg backend,可以使用以下语句: mngr = plt.get_current_fig_manager() # 获取当前figure manager mngr.window.wm_geometry("+380+310") # 调整窗口在屏幕上弹出的位置其中+380 指窗口左上角顶点的横坐标向X轴正方向移动380, +310 指窗口左上角顶点的纵坐标向Y轴正方向移动310。 完整代码: import matplotlib.pyplot as plt from PIL import Image img = Image.open("filepath") # 打开图片,返回PIL image对象 plt.figure(figsize=(4, 4)) mngr = plt.get_current_fig_manager() mngr.window.wm_geometry("+380+310") # 调整窗口在屏幕上弹出的位置 plt.ion() # 打开交互模式 plt.axis('off') # 不需要坐标轴 plt.imshow(img) plt.pause(15) # 该句显示图片15秒 plt.ioff() # 显示完后一定要配合使用plt.ioff()关闭交互模式,否则可能出奇怪的问题 plt.clf() # 清空图片 plt.close() # 清空窗口
|
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |