问题
I want to extent the python plots I am plotting using mpld3 to full screen. I wish to use mpld3 due to the following reasons
- I wish to have around 4 plots and have the zoom option for each plot.
- 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. 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?
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()
- Check this link for output of the code http://i.stack.imgur.com/4mBRI.png
回答1:
I think the size is defined by matplotlib, this means that adjusting this would result in a fullscreen plot.
From this topic: How to maximize a plt.show() window using Python
mng = plt.get_current_fig_manager()
mng.frame.Maximize(True)
Something like this might work.
回答2:
fig.set_size_inches(x_val,y_val)
helped me resize the plot to fit the screen
回答3:
Use window.state
option to get a zoomed version:
plt.get_current_fig_manager().window.state('zoomed')
来源:https://stackoverflow.com/questions/28187202/extend-python-plots-to-full-screen