简体   繁体   English

将python图扩展到全屏

[英]Extend python plots to full screen

I want to extent the python plots I am plotting using mpld3 to full screen. 我想将我使用mpld3绘制的python图扩展到全屏显示。 I wish to use mpld3 due to the following reasons 由于以下原因,我希望使用mpld3

  • I wish to have around 4 plots and have the zoom option for each plot. 我希望大约有4个图,并且每个图都有缩放选项。
  • All plots must be displayed in the same window. 所有图必须显示在同一窗口中。

Here, I tried using tight_layout option to extend the plots to occupy full screen but it does not work as shown in the link at the end.I guess tight_layout does not work with mpld3. 在这里,我尝试使用tight_layout选项将图扩展到全屏显示,但不能如最后链接所示那样工作。我猜tight_layout不适用于mpld3。 Is there any other way to make it stretch to full screen? 还有其他方法可以使其扩展到全屏显示吗?

Also,how do I add text to the screen where am plotting? 另外,如何在要绘制的屏幕上添加文本? Like the 4 plots occupying 90% of the screen from top to bottom and the text occupying remaining 10% at the bottom? 就像这4个地块从上到下占据了屏幕的90%,文本在底部占据了剩余的10%?

import matplotlib.pyplot as plt
import mpld3


x = [1,2,3]
y = [1,4,9]

fig = plt.figure()
ax = fig.add_subplot(411)
ax.plot(x,y)
ax = fig.add_subplot(412)
ax.plot(x,y)
ax = fig.add_subplot(413)
ax.plot(x,y)
ax = fig.add_subplot(414)
ax.plot(x,y)
fig.tight_layout()
mpld3.show()

I think the size is defined by matplotlib, this means that adjusting this would result in a fullscreen plot. 我认为大小是由matplotlib定义的,这意味着调整此大小将导致全屏显示。

From this topic: How to maximize a plt.show() window using Python 来自本主题: 如何使用Python最大化plt.show()窗口

mng = plt.get_current_fig_manager()
mng.frame.Maximize(True)

Something like this might work. 这样的事情可能会起作用。

fig.set_size_inches(x_val,y_val)

帮助我调整了绘图的大小以适合屏幕

使用window.state选项获取缩放版本:

plt.get_current_fig_manager().window.state('zoomed')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM