Commit c9779a35 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

fixes saving .png figure in full size

parent 36f34498
Loading
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -7,15 +7,11 @@ import sys
import struct
import numpy as np
import pandas as pd

import matplotlib
import tkinter
matplotlib.use('TkAgg')   # Qt4Agg  TkAgg Gtk3Agg
import matplotlib.pyplot as plt

# set matplotlib in interactive mode (plots figure and return control)
plt.ion()
plt.close('all')
# plt.ion()
# plt.close('all')

parser = argparse.ArgumentParser(description='Analyze memory output file')
parser.add_argument('input',type=str,help='Memory analysis file (e.g. mem_analysis.csv)')
@@ -30,8 +26,6 @@ Nframes = max(df['frame'])
df = df.groupby(df.columns.tolist(),as_index=False).size()
df = df.rename(columns={'size': 'count'})

# df.loc[df['action_type'] == 'D', 'frame'] += 0.9

# remove column 'action_type'
df.drop(columns = ['action_type'])

@@ -102,13 +96,15 @@ ax.set_position([box.x0, box.y0 + box.height * 0.2, box.width, box.height * 0.8]
# insert the legend below the graph         
ax.legend(loc="upper left", bbox_to_anchor=(0, -0.1), ncol=2, borderaxespad=0, fontsize='small')

# magnify to "almost" fullscreen size
# magnify to "almost" fullscreen size (select the alternative for your backend)
fig = plt.gcf()
fig.set_size_inches(15, 9)      # we need to set the size manually, otherwise savefig will save the figure in the default size
mng = plt.get_current_fig_manager()
mng.full_screen_toggle()
# mng.frame.Maximize(True)
# mng.window.showMaximized()
# mng.window.state('zoomed')

# show and save the figure
# show and save the figure (use block=True to wait until Figure is closed manually)
plt.savefig(os.path.splitext(args.input)[0] + '.png', dpi=100, bbox_inches='tight')
plt.show(block=True)
# plt.savefig(os.path.splitext(args.input)[0] + '.png', dpi=600)