I\'m building a small graphing utility using Pandas and MatPlotLib to parse data and output graphs from a machine at work.
When I output the graph using
<
As one more option, I think it is also worth looking into
plt.savefig('filename.png', bbox_inches='tight')
This is especially useful if you're doing subplots that has axis labels which look cluttered.
For those that receive errors in the answers above, this has worked for me.
#Show full screen
mng = plt.get_current_fig_manager()
mng.full_screen_toggle()
For everyone, who failed to save the plot in fullscreen using the above solutions, here is what really worked for me:
figure = plt.gcf() # get current figure
figure.set_size_inches(32, 18) # set figure's size manually to your full screen (32x18)
plt.savefig('filename.png', bbox_inches='tight') # bbox_inches removes extra white spaces
You may also want to play with the dpi (The resolution in dots per inch)
plt.savefig('filename.png', bbox_inches='tight', dpi=100)
The method you use to maximise the window size depends on which matplotlib backend you are using. Please see the following example for the 3 most common backends:
import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2], [1,2])
# Option 1
# QT backend
manager = plt.get_current_fig_manager()
manager.window.showMaximized()
# Option 2
# TkAgg backend
manager = plt.get_current_fig_manager()
manager.resize(*manager.window.maxsize())
# Option 3
# WX backend
manager = plt.get_current_fig_manager()
manager.frame.Maximize(True)
plt.show()
plt.savefig('sampleFileName.png')
You can determine which backend you are using with the command matplotlib.get_backend()
. When you save the maximized version of the figure it will save a larger image as desired.
I've found the most common answer on this website. It's a ragbag of all of those answers. It seems that it can be used in all cases without compatibility problems.
Don't hesitate to comment if you have some troubles with this answer.
# Maximise the plotting window
plot_backend = matplotlib.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()