python画图显示不全屏_关于matplotlib:如何使用Python最大化plt.show()窗口

出于好奇,我想在下面的代码中知道如何执行此操作。 我一直在寻找答案,但没有用。

import numpy as np

import matplotlib.pyplot as plt

data=np.random.exponential(scale=180, size=10000)

print ('el valor medio de la distribucion exponencial es: ')

print np.average(data)

plt.hist(data,bins=len(data)**0.5,normed=True, cumulative=True, facecolor='red', label='datos tamano paqutes acumulativa', alpha=0.5)

plt.legend()

plt.xlabel('algo')

plt.ylabel('algo')

plt.grid()

plt.show()

Spoiler,在Windows上工作:先按plt.get_current_fig_manager().window.state(zoomed),再按plt.show()。

由于我的信誉为零,因此我只能留下新的答案

我在运行Python 2.7.5和Matplotlib 1.3.1的Windows(WIN7)上

我能够使用以下几行来最大化TkAgg,QT4Agg和wxAgg的Figure窗口:

from matplotlib import pyplot as plt

### for 'TkAgg' backend

plt.figure(1)

plt.switch_backend('TkAgg') #TkAgg (instead Qt4Agg)

print '#1 Backend:',plt.get_backend()

plt.plot([1,2,6,4])

mng = plt.get_current_fig_manager()

### works on Ubuntu??? >> did NOT working on windows

# mng.resize(*mng.window.maxsize())

mng.window.state('zoomed') #works fine on Windows!

plt.show() #close the figure to run the next section

### for 'wxAgg' backend

plt.figure(2)

plt.switch_backend('wxAgg')

print '#2 Backend:',plt.get_backend()

plt.plot([1,2,6,4])

mng = plt.get_current_fig_manager()

mng.frame.Maximize(True)

plt.show() #close the figure to run the next section

### for 'Qt4Agg' backend

plt.figure(3)

plt.switch_backend('QT4Agg') #default on my system

print '#3 Backend:',plt.get_backend()

plt.plot([1,2,6,4])

figManager = plt.get_current_fig_manager()

figManager.window.showMaximized()

plt.show()

希望将以上答案的摘要(和一些

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值