Ken*_*ger 9 python numpy matplotlib python-2.7 python-3.x
我试图显示一个情节,但在全屏。这是我的代码:
import numpy as np
import pylab as plt
a = np.array([1,2,3,4])
b = np.array([1,2,3,4])
plt.plot(a,b,'.')
plt.show()
Run Code Online (Sandbox Code Playgroud)
But the problem is : this does not display with the fullscreen. Any ideas to solve this ? Thank you.
Tai*_*one 10
接受的答案中提供的代码将最大化数字,但不会以全屏模式显示。
如果您保留对该图的引用,则可以通过以下方式切换全屏模式:
import matplotlib.pyplot as plt
fig = plt.figure()
fig.canvas.manager.full_screen_toggle() # toggle fullscreen mode
fig.show()
Run Code Online (Sandbox Code Playgroud)
或者,如果您没有保留参考:
import matplotlib.pyplot as plt
plt.figure()
plt.get_current_fig_manager().full_screen_toggle() # toggle fullscreen mode
plt.show()
Run Code Online (Sandbox Code Playgroud)
要使用键盘切换全屏模式,只需按f或Ctrl+f。
这取决于你的 matplotlib 后端。对于 Qt,您可以编写以下代码来最大化绘图窗口:
manager = plt.get_current_fig_manager()
manager.window.showMaximized()
Run Code Online (Sandbox Code Playgroud)
并阅读这个问题:Saving Matplotlib graphs to image as full screen