In [1]:
%matplotlib inline
In [2]:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
In [3]:
def fig_size(fig_width_pt):
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
return (fig_width, fig_height)
In [74]:
params = {
'backend': 'ps',
'axes.labelsize': 10,
'text.fontsize': 10,
'legend.fontsize': 10,
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'text.usetex': True,
'figure.figsize': fig_size(450.0),
}; params
Out[74]:
In [5]:
data_filenames = [
('SIFT+SIFT', '../data/siftsift.txt'),
('SURF+SURF', '../data/surfsurf.txt'),
('FAST+SIFT', '../data/fastsift.txt'),
('FAST+SURF', '../data/fastsurf.txt'),
('FAST+BRIEF', '../data/fastbrief.txt'),
]
In [6]:
data = {}
for data_desc, data_filename in data_filenames:
with open(data_filename, 'r') as infile:
data[data_desc] = pd.Series(map(lambda line: float(line.split(' ')[-1]), infile.readlines()))
In [7]:
data['SIFT+SIFT'].plot()
Out[7]:
In [8]:
data['SIFT+SIFT'].plot(ylim=(0, 1))
Out[8]:
In [9]:
df = pd.DataFrame(data); df
Out[9]:
In [11]:
df.plot()
Out[11]:
In [12]:
df.plot(ylim=(0, 1))
Out[12]:
In [13]:
df.columns
Out[13]:
In [14]:
df['FAST+BRIEF']
Out[14]:
In [17]:
fig, axes = plt.subplots()
df.plot(ax=axes, ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[17]:
In [19]:
fig, axes = plt.subplots()
df.plot(ax=axes, xlim=(0, 100), ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[19]:
In [23]:
fig, axes = plt.subplots()
df.plot(ax=axes, kind='area', ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[23]:
In [32]:
fig, axes = plt.subplots()
df.plot(ax=axes, logx=True, ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[32]:
In [37]:
fig, axes = plt.subplots()
df.plot(ax=axes, xlim=(200, 300), ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[37]:
In [38]:
from matplotlib.lines import Line2D
In [39]:
Line2D.markers
Out[39]:
In [42]:
filter(lambda k: Line2D.markers[k] != 'nothing', Line2D.markers)
Out[42]:
In [45]:
linestyles = ['_', '-', '--', ':'] + filter(lambda k: Line2D.markers[k] != 'nothing', Line2D.markers)
In [58]:
fig, axes = plt.subplots()
df.plot(ax=axes, ylim=(0, 1), style=['+', '*', '1', 'x', 'o'])
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[58]:
In [60]:
fig, axes = plt.subplots()
df.plot(ax=axes, xlim=(0, 100), ylim=(0, 1), style=['+', '*', '1', 'x', 'o'])
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[60]:
In [63]:
fig, axes = plt.subplots()
df.plot(ax=axes, logx=True, ylim=(0, 1.2))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
Out[63]:
In [75]:
with plt.rc_context(params):
fig, axes = plt.subplots()
df.plot(ax=axes, logx=True, ylim=(0, 1.2))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
In [79]:
with plt.rc_context(params):
fig, axes = plt.subplots()
df.plot(ax=axes, logx=True, ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
fig.savefig('../figures/plot.eps')
In [80]:
with plt.rc_context(params):
fig, axes = plt.subplots()
df.plot(ax=axes, logx=True, ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
fig.savefig('../figures/reproducibility.eps')
In [81]:
with plt.rc_context(params):
fig, axes = plt.subplots()
df.plot(ax=axes, logx=True, ylim=(0, 1))
axes.legend(loc='upper left')
axes.set_xlabel('time (frame number)')
axes.set_ylabel('reproducibility rate')
fig.savefig('../figures/reproducibility.pdf')
In [ ]: