4

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()
Ram
  • 634
  • 1
  • 9
  • 22

3 Answers3

3

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.

Community
  • 1
  • 1
3
fig.set_size_inches(x_val,y_val)

helped me resize the plot to fit the screen

eebbesen
  • 5,070
  • 8
  • 48
  • 70
Ram
  • 634
  • 1
  • 9
  • 22
3

Use window.state option to get a zoomed version:

plt.get_current_fig_manager().window.state('zoomed')
Ulysses
  • 5,616
  • 7
  • 48
  • 84
  • Finally an option that doesn't cause error. There is one quirk on Windows (at least on my multi DPI monitor setup) that when window is restored by pulling it down, it becomes very small... Restoring by double-clicking works fine though. – Radzor Nov 08 '20 at 03:50