我想将我使用 mpld3 绘制的 python 图扩展到全屏。由于以下原因,我希望使用 mpld3
- 我希望有大约 4 个地 block ,每个地 block 都有缩放选项。
- 所有绘图必须显示在同一窗口中。
在这里,我尝试使用 tight_layout 选项来扩展绘图以占据全屏,但它不起作用,如最后的链接所示。我猜 tight_layout 不适用于 mpld3。有没有其他方法让它拉伸(stretch)到全屏?
此外,如何将文本添加到正在绘图的屏幕上?比如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()
- 检查此链接以获取代码的输出 http://i.stack.imgur.com/4mBRI.png
最佳答案
我认为大小是由 matplotlib 定义的,这意味着调整它会导致全屏绘图。
来自本主题:How to maximize a plt.show() window using Python
mng = plt.get_current_fig_manager()
mng.frame.Maximize(True)
这样的事情可能会奏效。
关于python - 将 python 图扩展到全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28187202/