I'm using Windows XP v3/Python 2.7 with Canopy and Anaconda package managers/editors.
I am using Python/Matplotlib to produce some Bland-Altman plots (statistical scatter plots) for publication.
After processing the data, the plt.show() command opens a new "Figure" window containing the plot, which looks fine.
I want to be able to use the dynamic pan and zoom commands in this window to interactively optimise the appearance of my plot, then save it as it appears in the window as a high resolution press-quality png image (400-600 dpi, 7 x 5 inches).
The default setting for saving images from the "Figure" window appears to be set to screen resolution (800 x 600 pixels), and I cannot find any options in this window which allow me to change these settings.
I've read other posts on this forum which explain how to directly save a plot from Python in higher resolution by using the following commands to manipulate dpi and image size, e.g.:
plt.figure(figsize=(18, 12), dpi=400)
plt.savefig("myplot.png", dpi = 400)
However, this is not the solution that I'm looking for; as I want to be able to modify the plot using the dynamic pan and zoom features of the "Figure" window before saving in a higher resolution than the default screen resolution.
I'd be grateful for your help.
Many thanks in anticipation & Happy New Year.
Dave
(UK)
Try this:
Determine how to set width and height using a pixels-to-inches converter, like in the following matplotlib documentation. Then try:
import matplotlib.pyplot as plt
fig = plt.figure(frameon=False)
fig.set_size_inches(width,height)
I had this issue in spyder and found changing the value in Preferences > iPython Console > Inline Backend > Resolution changes the resolution when I save figures from the built in window viewing application.
One may register an event upon a key press that would save the figure with some previously given size and dpi. The following uses a class that stores some figsize and dpi and upon pressing t wll change the figure size and dpi of the figure. It will then save this figure and restore the old size and dpi such that the figure on screen remains unchanged.
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
fig,ax=plt.subplots()
ax.plot([1,3,1])
class AnySizeSaver():
def __init__(self, fig=None, figsize=None, dpi=None, filename=None):
if not fig: fig=plt.gcf()
self.fig = fig
if not figsize: figsize=self.fig.get_size_inches()
self.figsize=figsize
if not dpi: dpi=self.fig.dpi
self.dpi=dpi
if not filename: filename="myplot.png"
self.filename=filename
self.cid = self.fig.canvas.mpl_connect("key_press_event", self.key_press)
def key_press(self, event):
if event.key == "t":
self.save()
def save(self):
oldfigsize = self.fig.get_size_inches()
olddpi=self.fig.dpi
self.fig.set_size_inches(self.figsize)
self.fig.set_dpi(self.dpi)
self.fig.savefig(self.filename, dpi=self.dpi)
self.fig.set_size_inches(oldfigsize, forward=True)
self.fig.set_dpi(olddpi)
self.fig.canvas.draw_idle()
print(fig.get_size_inches())
ass = AnySizeSaver(fig=fig, figsize=(3,3), dpi=600)
plt.show()
Related
In this link, they explain how to use subplots and save the result as an .mp4 file. It works great. However, it saves the video as if the window were not maximized. here, they explain how to automatically maximize when displaying, that is, when using plt.show(), which works. But again, when saving automatically by using .save, it does not save the maximized the version. Does anyone know how to do that (if it is not too complicated)?
Thanks!
You can obtain the dimensions you want by adjusting figsize using:
fig, ax = plt.subplots(figsize=(20, 10))
where 20 and 10 are respectively width and height of the figure in inches
and you can also provide a dpi option (defaults to 100) :
fig, ax = plt.subplots(figsize=(20, 10), dpi=80)
When you save the figure, dpi option is still available:
plt.savefig("test.png", dpi=80)
For animations, it's the same:
ani.save("test.mp4", dpi=80)
Just for curiosity I would like to know how to do this in the code below. I have been searching for an answer but is useless.
import numpy as np
import matplotlib.pyplot as plt
data=np.random.exponential(scale=180, size=10000)
print ('el valor medio de la distribucion exponencial es: ')
print np.average(data)
plt.hist(data,bins=len(data)**0.5,normed=True, cumulative=True, facecolor='red', label='datos tamano paqutes acumulativa', alpha=0.5)
plt.legend()
plt.xlabel('algo')
plt.ylabel('algo')
plt.grid()
plt.show()
I am on a Windows (WIN7), running Python 2.7.5 & Matplotlib 1.3.1.
I was able to maximize Figure windows for TkAgg, QT4Agg, and wxAgg using the following lines:
from matplotlib import pyplot as plt
### for 'TkAgg' backend
plt.figure(1)
plt.switch_backend('TkAgg') #TkAgg (instead Qt4Agg)
print '#1 Backend:',plt.get_backend()
plt.plot([1,2,6,4])
mng = plt.get_current_fig_manager()
### works on Ubuntu??? >> did NOT working on windows
# mng.resize(*mng.window.maxsize())
mng.window.state('zoomed') #works fine on Windows!
plt.show() #close the figure to run the next section
### for 'wxAgg' backend
plt.figure(2)
plt.switch_backend('wxAgg')
print '#2 Backend:',plt.get_backend()
plt.plot([1,2,6,4])
mng = plt.get_current_fig_manager()
mng.frame.Maximize(True)
plt.show() #close the figure to run the next section
### for 'Qt4Agg' backend
plt.figure(3)
plt.switch_backend('QT4Agg') #default on my system
print '#3 Backend:',plt.get_backend()
plt.plot([1,2,6,4])
figManager = plt.get_current_fig_manager()
figManager.window.showMaximized()
plt.show()
if you want to maximize multiple figures you can use
for fig in figs:
mng = fig.canvas.manager
# ...
Hope this summary of the previous answers (and some additions) combined in a working example (at least for windows) helps.
With Qt backend (FigureManagerQT) proper command is:
figManager = plt.get_current_fig_manager()
figManager.window.showMaximized()
This makes the window take up the full screen for me, under Ubuntu 12.04 with the TkAgg backend:
mng = plt.get_current_fig_manager()
mng.resize(*mng.window.maxsize())
This should work (at least with TkAgg):
wm = plt.get_current_fig_manager()
wm.window.state('zoomed')
(adopted from the above and Using Tkinter, is there a way to get the usable screen size without visibly zooming a window?)
For me nothing of the above worked. I use the Tk backend on Ubuntu 14.04 which contains matplotlib 1.3.1.
The following code creates a fullscreen plot window which is not the same as maximizing but it serves my purpose nicely:
from matplotlib import pyplot as plt
mng = plt.get_current_fig_manager()
mng.full_screen_toggle()
plt.show()
I usually use
mng = plt.get_current_fig_manager()
mng.frame.Maximize(True)
before the call to plt.show(), and I get a maximized window. This works for the 'wx' backend only.
EDIT:
for Qt4Agg backend, see kwerenda's answer.
My best effort so far, supporting different backends:
from platform import system
def plt_maximize():
# See discussion: https://stackoverflow.com/questions/12439588/how-to-maximize-a-plt-show-window-using-python
backend = plt.get_backend()
cfm = plt.get_current_fig_manager()
if backend == "wxAgg":
cfm.frame.Maximize(True)
elif backend == "TkAgg":
if system() == "Windows":
cfm.window.state("zoomed") # This is windows only
else:
cfm.resize(*cfm.window.maxsize())
elif backend == "QT4Agg":
cfm.window.showMaximized()
elif callable(getattr(cfm, "full_screen_toggle", None)):
if not getattr(cfm, "flag_is_max", None):
cfm.full_screen_toggle()
cfm.flag_is_max = True
else:
raise RuntimeError("plt_maximize() is not implemented for current backend:", backend)
I get mng.frame.Maximize(True) AttributeError: FigureManagerTkAgg instance has no attribute 'frame' as well.
Then I looked through the attributes mng has, and I found this:
mng.window.showMaximized()
That worked for me.
So for people who have the same trouble, you may try this.
By the way, my Matplotlib version is 1.3.1.
This is kind of hacky and probably not portable, only use it if you're looking for quick and dirty. If I just set the figure much bigger than the screen, it takes exactly the whole screen.
fig = figure(figsize=(80, 60))
In fact, in Ubuntu 16.04 with Qt4Agg, it maximizes the window (not full-screen) if it's bigger than the screen. (If you have two monitors, it just maximizes it on one of them).
I found this for full screen mode on Ubuntu
#Show full screen
mng = plt.get_current_fig_manager()
mng.full_screen_toggle()
import matplotlib.pyplot as plt
def maximize():
plot_backend = plt.get_backend()
mng = plt.get_current_fig_manager()
if plot_backend == 'TkAgg':
mng.resize(*mng.window.maxsize())
elif plot_backend == 'wxAgg':
mng.frame.Maximize(True)
elif plot_backend == 'Qt4Agg':
mng.window.showMaximized()
Then call function maximize() before plt.show()
The one solution that worked on Win 10 flawlessly.
import matplotlib.pyplot as plt
plt.plot(x_data, y_data)
mng = plt.get_current_fig_manager()
mng.window.state("zoomed")
plt.show()
For backend GTK3Agg, use maximize() – notably with a lower case m:
manager = plt.get_current_fig_manager()
manager.window.maximize()
Tested in Ubuntu 20.04 with Python 3.8.
Pressing the f key (or ctrl+f in 1.2rc1) when focussed on a plot will fullscreen a plot window. Not quite maximising, but perhaps better.
Other than that, to actually maximize, you will need to use GUI Toolkit specific commands (if they exist for your specific backend).
HTH
Here is a function based on #Pythonio's answer. I encapsulate it into a function that automatically detects which backend is it using and do the corresponding actions.
def plt_set_fullscreen():
backend = str(plt.get_backend())
mgr = plt.get_current_fig_manager()
if backend == 'TkAgg':
if os.name == 'nt':
mgr.window.state('zoomed')
else:
mgr.resize(*mgr.window.maxsize())
elif backend == 'wxAgg':
mgr.frame.Maximize(True)
elif backend == 'Qt4Agg':
mgr.window.showMaximized()
In my versions (Python 3.6, Eclipse, Windows 7), snippets given above didn't work, but with hints given by Eclipse/pydev (after typing: mng.), I found:
mng.full_screen_toggle()
It seems that using mng-commands is ok only for local development...
Try using 'Figure.set_size_inches' method, with the extra keyword argument forward=True. According to the documentation, this should resize the figure window.
Whether that actually happens will depend on the operating system you are using.
Try plt.figure(figsize=(6*3.13,4*3.13)) to make the plot larger.
Ok so this is what worked for me. I did the whole showMaximize() option and it does resize your window in proportion to the size of the figure, but it does not expand and 'fit' the canvas. I solved this by:
mng = plt.get_current_fig_manager()
mng.window.showMaximized()
plt.tight_layout()
plt.savefig('Images/SAVES_PIC_AS_PDF.pdf')
plt.show()
For Tk-based backend (TkAgg), these two options maximize & fullscreen the window:
plt.get_current_fig_manager().window.state('zoomed')
plt.get_current_fig_manager().window.attributes('-fullscreen', True)
When plotting into multiple windows, you need to write this for each window:
data = rasterio.open(filepath)
blue, green, red, nir = data.read()
plt.figure(1)
plt.subplot(121); plt.imshow(blue);
plt.subplot(122); plt.imshow(red);
plt.get_current_fig_manager().window.state('zoomed')
rgb = np.dstack((red, green, blue))
nrg = np.dstack((nir, red, green))
plt.figure(2)
plt.subplot(121); plt.imshow(rgb);
plt.subplot(122); plt.imshow(nrg);
plt.get_current_fig_manager().window.state('zoomed')
plt.show()
Here, both 'figures' are plotted in separate windows. Using a variable such as
figure_manager = plt.get_current_fig_manager()
might not maximize the second window, since the variable still refers to the first window.
I collected a few answers from the threads I was looking at when trying to achieve the same thing. This is the function I am using right now which maximizes all plots and doesn't really care about the backend being used. I run it at the end of the script. It does still run into the problem mentioned by others using multiscreen setups, in that fm.window.maxsize() will get the total screen size rather than just that of the current monitor. If you know the screensize you want them you can replace *fm.window.maxsize() with the tuple (width_inches, height_inches).
Functionally all this does is grab a list of figures, and resize them to matplotlibs current interpretation of the current maximum window size.
def maximizeAllFigures():
'''
Maximizes all matplotlib plots.
'''
for i in plt.get_fignums():
plt.figure(i)
fm = plt.get_current_fig_manager()
fm.resize(*fm.window.maxsize())
I have tried most of above solutions but none of them works well on my Windows 10 with Python 3.10.5.
Below is what I found that works perfectly on my side.
import ctypes
mng = plt.get_current_fig_manager()
mng.resize(ctypes.windll.user32.GetSystemMetrics(0), ctypes.windll.user32.GetSystemMetrics(1))
This doesn't necessarily maximize your window, but it does resize your window in proportion to the size of the figure:
from matplotlib import pyplot as plt
F = gcf()
Size = F.get_size_inches()
F.set_size_inches(Size[0]*2, Size[1]*2, forward=True)#Set forward to True to resize window along with plot in figure.
plt.show() #or plt.imshow(z_array) if using an animation, where z_array is a matrix or numpy array
This might also help: http://matplotlib.1069221.n5.nabble.com/Resizing-figure-windows-td11424.html
The following may work with all the backends, but I tested it only on QT:
import numpy as np
import matplotlib.pyplot as plt
import time
plt.switch_backend('QT4Agg') #default on my system
print('Backend: {}'.format(plt.get_backend()))
fig = plt.figure()
ax = fig.add_axes([0,0, 1,1])
ax.axis([0,10, 0,10])
ax.plot(5, 5, 'ro')
mng = plt._pylab_helpers.Gcf.figs.get(fig.number, None)
mng.window.showMaximized() #maximize the figure
time.sleep(3)
mng.window.showMinimized() #minimize the figure
time.sleep(3)
mng.window.showNormal() #normal figure
time.sleep(3)
mng.window.hide() #hide the figure
time.sleep(3)
fig.show() #show the previously hidden figure
ax.plot(6,6, 'bo') #just to check that everything is ok
plt.show()
When I save a matplotlib figure as a jpeg the tick fonts are pixelated. I'm not sure what is going on or if there is any hack to fix this. Does anyone have any insight?
%matplotlib nbagg
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1.2,1.2,1000,endpoint=True)
y = np.copy(x)
x,y = np.meshgrid(x,y)
z = -x**2 + y**2 - y**3
fig = plt.figure()
ax = fig.add_subplot(111)
CS = plt.contour(x,y,z, [0,-0.1,0.1], colors=['black','blue', 'gray'])
plt.clabel(CS, fontsize=14, inline=1, fmt='%1.1f', manual=[(-0.15,0), (-0.4,0), (0.25,0.5)])
plt.savefig('plot.png', format='png')
plt.savefig('plot.jpg', format='jpg')
plt.savefig('plot.tiff', format='tiff')
Here is plot.png:
Here is plot.jpg:
Here is the plot.tiff:
I believe this is related to a previous question I had: Anti-aliased Fonts in Animations
As noted above, this situation appears is dependent on the backend used. You can avoid the issue by using:
import matplotlib
matplotlib.use('webagg')
as opposed to:
%matplotlib nbagg
I believe the issue has to do with PIL trying to save a jpeg of a figure with transparency. If you insist on using nbagg, it appears that if you set:
matplotlib.rcParams['nbagg.transparent'] = False
Your jpeg image fonts won't be pixelated and will look nearly identical to the png and tiff files shown in the question. Unfortunately using the rcParams:
matplotlib.rcParams['savefig.transparent'] = False
is not sufficient. It appears that the 'savefig.transparent' rcParam will control the transparency of the plot inside the figure and the 'nbagg.transparent' will control the transparency outside of the figure (ie: axis, ticks, titles, etc..). There is probably an easy work by ensuring the backend forces transparency = False for when saving to file formats that don't support transparency.
Some of the other backends may not support transparency which is why it appears to fix the problem when you change backends.
I will report this to github as a bug.
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
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.
fig.set_size_inches(x_val,y_val)
helped me resize the plot to fit the screen
Use window.state option to get a zoomed version:
plt.get_current_fig_manager().window.state('zoomed')
I am using pylab in matplotlib to create a plot and save the plot to an image file. However, when I save the image using pylab.savefig( image_name ), I find that the SIZE image saved is the same as the image that is shown when I use pylab.show().
As it happens, I have a lot of data in the plot and when I am using pylab.show(), I have to maximize the window before I can see all of the plot correctly, and the xlabel tickers don't superimpose on each other.
Is there anyway that I can programmatically 'maximize' the window before saving the image to file? - at the moment, I am only getting the 'default' window size image, which results in the x axis labels being superimposed on one another.
There are two major options in matplotlib (pylab) to control the image size:
You can set the size of the resulting image in inches
You can define the DPI (dots per inch) for output file (basically, it is a resolution)
Normally, you would like to do both, because this way you will have full control over the resulting image size in pixels. For example, if you want to render exactly 800x600 image, you can use DPI=100, and set the size as 8 x 6 in inches:
import matplotlib.pyplot as plt
# plot whatever you need...
# now, before saving to file:
figure = plt.gcf() # get current figure
figure.set_size_inches(8, 6)
# when saving, specify the DPI
plt.savefig("myplot.png", dpi = 100)
One can use any DPI. In fact, you might want to play with various DPI and size values to get the result you like the most. Beware, however, that using very small DPI is not a good idea, because matplotlib may not find a good font to render legend and other text. For example, you cannot set the DPI=1, because there are no fonts with characters rendered with 1 pixel :)
From other comments I understood that other issue you have is proper text rendering. For this, you can also change the font size. For example, you may use 6 pixels per character, instead of 12 pixels per character used by default (effectively, making all text twice smaller).
import matplotlib
#...
matplotlib.rc('font', size=6)
Finally, some references to the original documentation:
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.savefig, http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.gcf, http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.set_size_inches, http://matplotlib.sourceforge.net/users/customizing.html#dynamic-rc-settings
P.S. Sorry, I didn't use pylab, but as far as I'm aware, all the code above will work same way in pylab - just replace plt in my code with the pylab (or whatever name you assigned when importing pylab). Same for matplotlib - use pylab instead.
You set the size on initialization:
fig2 = matplotlib.pyplot.figure(figsize=(8.0, 5.0)) # in inches!
Edit:
If the problem is with x-axis ticks - You can set them "manually":
fig2.add_subplot(111).set_xticks(arange(1,3,0.5)) # You can actually compute the interval You need - and substitute here
And so on with other aspects of Your plot. You can configure it all. Here's an example:
from numpy import arange
import matplotlib
# import matplotlib as mpl
import matplotlib.pyplot
# import matplotlib.pyplot as plt
x1 = [1,2,3]
y1 = [4,5,6]
x2 = [1,2,3]
y2 = [5,5,5]
# initialization
fig2 = matplotlib.pyplot.figure(figsize=(8.0, 5.0)) # The size of the figure is specified as (width, height) in inches
# lines:
l1 = fig2.add_subplot(111).plot(x1,y1, label=r"Text $formula$", "r-", lw=2)
l2 = fig2.add_subplot(111).plot(x2,y2, label=r"$legend2$" ,"g--", lw=3)
fig2.add_subplot(111).legend((l1,l2), loc=0)
# axes:
fig2.add_subplot(111).grid(True)
fig2.add_subplot(111).set_xticks(arange(1,3,0.5))
fig2.add_subplot(111).axis(xmin=3, xmax=6) # there're also ymin, ymax
fig2.add_subplot(111).axis([0,4,3,6]) # all!
fig2.add_subplot(111).set_xlim([0,4])
fig2.add_subplot(111).set_ylim([3,6])
# labels:
fig2.add_subplot(111).set_xlabel(r"x $2^2$", fontsize=15, color = "r")
fig2.add_subplot(111).set_ylabel(r"y $2^2$")
fig2.add_subplot(111).set_title(r"title $6^4$")
fig2.add_subplot(111).text(2, 5.5, r"an equation: $E=mc^2$", fontsize=15, color = "y")
fig2.add_subplot(111).text(3, 2, unicode('f\374r', 'latin-1'))
# saving:
fig2.savefig("fig2.png")
So - what exactly do You want to be configured?
I think you need to specify a different resolution when saving the figure to a file:
fig = matplotlib.pyplot.figure()
# generate your plot
fig.savefig("myfig.png",dpi=600)
Specifying a large dpi value should have a similar effect as maximizing the GUI window.
Check this:
How to maximize a plt.show() window using Python
The command is different depending on which backend you use. I find that this is the best way to make sure the saved pictures have the same scaling as what I view on my screen.
Since I use Canopy with the QT backend:
pylab.get_current_fig_manager().window.showMaximized()
I then call savefig() as required with an increased DPI per silvado's answer.
You can look in a saved figure it's size, like 1920x983 px (size when i saved a maximized window), then I set the dpi as 100 and the size as 19.20x9.83 and it worked fine. Saved exactly equal to the maximized figure.
import numpy as np
import matplotlib.pyplot as plt
x, y = np.genfromtxt('fname.dat', usecols=(0,1), unpack=True)
a = plt.figure(figsize=(19.20,9.83))
a = plt.plot(x, y, '-')
plt.savefig('file.png',format='png',dpi=100)
I had this exact problem and this worked:
plt.savefig(output_dir + '/xyz.png', bbox_inches='tight')
Here is the documentation:
[https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html][1]
I did the same search time ago, it seems that he exact solution depends on the backend.
I have read a bunch of sources and probably the most useful was the answer by Pythonio here How to maximize a plt.show() window using Python
I adjusted the code and ended up with the function below.
It works decently for me on windows, I mostly use Qt, where I use it quite often, while it is minimally tested with other backends.
Basically it consists in identifying the backend and calling the appropriate function. Note that I added a pause afterwards because I was having issues with some windows getting maximized and others not, it seems this solved for me.
def maximize(backend=None,fullscreen=False):
"""Maximize window independently on backend.
Fullscreen sets fullscreen mode, that is same as maximized, but it doesn't have title bar (press key F to toggle full screen mode)."""
if backend is None:
backend=matplotlib.get_backend()
mng = plt.get_current_fig_manager()
if fullscreen:
mng.full_screen_toggle()
else:
if backend == 'wxAgg':
mng.frame.Maximize(True)
elif backend == 'Qt4Agg' or backend == 'Qt5Agg':
mng.window.showMaximized()
elif backend == 'TkAgg':
mng.window.state('zoomed') #works fine on Windows!
else:
print ("Unrecognized backend: ",backend) #not tested on different backends (only Qt)
plt.show()
plt.pause(0.1) #this is needed to make sure following processing gets applied (e.g. tight_layout)
Old question but to anyone in need, Here's what had worked for me a while ago:
You have to have a general idea of the aspect ratio that would maximise your plot fitting. This will take some trial and error to get right, but generally 1920x1080 would be a good aspect ratio for most modern monitors. I would still suggest playing around with the aspect ratios to best suit your plot.
Steps:
Before initiating the plot, set the size for the plot, use:
plt.figure(19.20, 10.80)
**notice how I have multiplied my aspect ratio by '0.01'.
At the end of the plot, when using plt.savefig, save it as follows:
plt.savefig('name.jpg', bbox_inches='tight', dpi=1000)
If I understand correctly what you want to do, you can create your figure and set the size of the window. Afterwards, you can save your graph with the matplotlib toolbox button. Here an example:
from pylab import get_current_fig_manager,show,plt,imshow
plt.Figure()
thismanager = get_current_fig_manager()
thismanager.window.wm_geometry("500x500+0+0")
#in this case 500 is the size (in pixel) of the figure window. In your case you want to maximise to the size of your screen or whatever
imshow(your_data)
show()