Created
October 19, 2014 18:24
-
-
Save bkamapantula/25a931bedd76ffabab74 to your computer and use it in GitHub Desktop.
Boxplot in python using pandas, matplotlib | Vary position of figure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt | |
import sys | |
import os | |
import matplotlib as mpl | |
pd.options.display.mpl_style = 'default' | |
def box_plot(): | |
f = open(sys.argv[1], "r") | |
image_name = os.path.splitext(sys.argv[1])[0]+".pdf" | |
vals = pd.DataFrame.from_csv(f, sep='\t', index_col=False) #, columns=['20']) | |
fig = plt.figure(); | |
ax = fig.add_subplot(111) | |
bp = vals.boxplot() | |
plt.xlabel('Loss (%)') | |
plt.ylabel('Packet receipt rate (%)') | |
# sets font size | |
font = {'family' : 'normal', | |
'weight' : 'bold', | |
'size' : 18} | |
mpl.rc('font', **font) | |
# gets axes position | |
fig_pos = ax.get_position() | |
# sets axes position; done to move figure vertically | |
ax.set_position([fig_pos.x0, fig_pos.y0+0.045, fig_pos.width, fig_pos.height]) | |
plt.savefig(image_name, format='pdf') | |
box_plot() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment