Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extend python plots to full screen

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 https://i.sstatic.net/4mBRI.png
like image 820
Ram Avatar asked Oct 15 '25 03:10

Ram


2 Answers

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.

like image 72
Joost Boonzajer Flaes Avatar answered Oct 16 '25 15:10

Joost Boonzajer Flaes


fig.set_size_inches(x_val,y_val)

helped me resize the plot to fit the screen

like image 33
Ram Avatar answered Oct 16 '25 16:10

Ram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!