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]:
{'axes.labelsize': 10,
 'backend': 'ps',
 'figure.figsize': (6.226650062266501, 3.848281374532347),
 'legend.fontsize': 10,
 'text.fontsize': 10,
 'text.usetex': True,
 'xtick.labelsize': 8,
 'ytick.labelsize': 8}

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]:
<matplotlib.axes._subplots.AxesSubplot at 0x108048910>

In [8]:
data['SIFT+SIFT'].plot(ylim=(0, 1))


Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x1080b5d90>

In [9]:
df = pd.DataFrame(data); df


Out[9]:
FAST+BRIEF FAST+SIFT FAST+SURF SIFT+SIFT SURF+SURF
0 0.508380 0.340909 0.442308 0.529183 0.486486
1 0.491620 0.342657 0.454545 0.513619 0.549550
2 0.519553 0.353147 0.426573 0.529183 0.549550
3 0.536313 0.363636 0.428322 0.533074 0.594595
4 0.603352 0.384615 0.414336 0.533074 0.585586
5 0.508380 0.325175 0.430070 0.459144 0.477477
6 0.519553 0.361888 0.403846 0.501946 0.513514
7 0.391061 0.305944 0.412587 0.431907 0.486486
8 0.318436 0.202797 0.377622 0.373541 0.396396
9 0.195531 0.134615 0.377622 0.284047 0.324324
10 0.156425 0.146853 0.328671 0.272374 0.324324
11 0.217877 0.054196 0.337413 0.175097 0.270270
12 0.162011 0.057692 0.307692 0.147860 0.243243
13 0.217877 0.094406 0.318182 0.186770 0.270270
14 0.145251 0.097902 0.307692 0.124514 0.288288
15 0.156425 0.071678 0.279720 0.151751 0.324324
16 0.195531 0.054196 0.286713 0.186770 0.252252
17 0.167598 0.054196 0.298951 0.178988 0.261261
18 0.178771 0.080420 0.284965 0.206226 0.315315
19 0.178771 0.113636 0.353147 0.284047 0.306306
20 0.134078 0.160839 0.386364 0.307393 0.378378
21 0.324022 0.234266 0.375874 0.377432 0.378378
22 0.480447 0.288462 0.368881 0.431907 0.414414
23 0.480447 0.316434 0.398601 0.420233 0.405405
24 0.318436 0.256993 0.393357 0.400778 0.522523
25 0.223464 0.281469 0.367133 0.365759 0.387387
26 0.212291 0.181818 0.389860 0.342412 0.351351
27 0.240223 0.187063 0.379371 0.311284 0.279279
28 0.201117 0.188811 0.391608 0.311284 0.342342
29 0.251397 0.232517 0.386364 0.350195 0.414414
... ... ... ... ... ...
1447 0.854749 0.762238 0.538462 0.618677 0.756757
1448 0.832402 0.777972 0.569930 0.603113 0.738739
1449 0.882682 0.777972 0.601399 0.634241 0.801802
1450 0.877095 0.784965 0.564685 0.649805 0.810811
1451 0.854749 0.774476 0.582168 0.607004 0.801802
1452 0.832402 0.748252 0.561189 0.568093 0.810811
1453 0.860335 0.748252 0.592657 0.607004 0.774775
1454 0.877095 0.755245 0.569930 0.603113 0.828829
1455 0.888268 0.772727 0.566434 0.634241 0.756757
1456 0.893855 0.763986 0.566434 0.642023 0.765766
1457 0.932961 0.786713 0.564685 0.669261 0.819820
1458 0.905028 0.765734 0.608392 0.626459 0.810811
1459 0.882682 0.793706 0.545455 0.587549 0.810811
1460 0.837989 0.770979 0.582168 0.607004 0.792793
1461 0.865922 0.776224 0.571678 0.622568 0.765766
1462 0.877095 0.769231 0.555944 0.642023 0.774775
1463 0.871508 0.755245 0.536713 0.642023 0.774775
1464 0.888268 0.783217 0.538462 0.634241 0.756757
1465 0.905028 0.774476 0.555944 0.642023 0.738739
1466 0.860335 0.781469 0.568182 0.630350 0.738739
1467 0.905028 0.753497 0.554196 0.626459 0.765766
1468 0.888268 0.765734 0.571678 0.610895 0.729730
1469 0.877095 0.784965 0.582168 0.634241 0.810811
1470 0.888268 0.776224 0.578671 0.610895 0.783784
1471 0.865922 0.774476 0.585664 0.583658 0.774775
1472 0.905028 0.784965 0.557692 0.638132 0.792793
1473 0.871508 0.790210 0.580420 0.630350 0.792793
1474 0.871508 0.805944 0.573427 0.618677 0.774775
1475 0.871508 0.797203 0.555944 0.595331 0.747748
1476 21.804800 3.844770 4.900680 4.903700 2.473130

1477 rows × 5 columns


In [11]:
df.plot()


Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x10813d7d0>

In [12]:
df.plot(ylim=(0, 1))


Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x108708e50>

In [13]:
df.columns


Out[13]:
Index([u'FAST+BRIEF', u'FAST+SIFT', u'FAST+SURF', u'SIFT+SIFT', u'SURF+SURF'], dtype='object')

In [14]:
df['FAST+BRIEF']


Out[14]:
0     0.508380
1     0.491620
2     0.519553
3     0.536313
4     0.603352
5     0.508380
6     0.519553
7     0.391061
8     0.318436
9     0.195531
10    0.156425
11    0.217877
12    0.162011
13    0.217877
14    0.145251
...
1462     0.877095
1463     0.871508
1464     0.888268
1465     0.905028
1466     0.860335
1467     0.905028
1468     0.888268
1469     0.877095
1470     0.888268
1471     0.865922
1472     0.905028
1473     0.871508
1474     0.871508
1475     0.871508
1476    21.804800
Name: FAST+BRIEF, Length: 1477, dtype: float64

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]:
<matplotlib.text.Text at 0x108d7ced0>

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]:
<matplotlib.text.Text at 0x1094af450>

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]:
<matplotlib.text.Text at 0x10ddb08d0>

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]:
<matplotlib.text.Text at 0x12d763910>

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]:
<matplotlib.text.Text at 0x13b490950>

In [38]:
from matplotlib.lines import Line2D

In [39]:
Line2D.markers


Out[39]:
{None: u'nothing',
 0: u'tickleft',
 1: u'tickright',
 2: u'tickup',
 3: u'tickdown',
 4: u'caretleft',
 5: u'caretright',
 6: u'caretup',
 7: u'caretdown',
 u'': u'nothing',
 u' ': u'nothing',
 u'*': u'star',
 u'+': u'plus',
 u',': u'pixel',
 u'.': u'point',
 u'1': u'tri_down',
 u'2': u'tri_up',
 u'3': u'tri_left',
 u'4': u'tri_right',
 u'8': u'octagon',
 u'<': u'triangle_left',
 u'>': u'triangle_right',
 u'D': u'diamond',
 u'H': u'hexagon2',
 u'None': u'nothing',
 u'^': u'triangle_up',
 u'_': u'hline',
 u'd': u'thin_diamond',
 u'h': u'hexagon1',
 u'o': u'circle',
 u'p': u'pentagon',
 u's': u'square',
 u'v': u'triangle_down',
 u'x': u'x',
 u'|': u'vline'}

In [42]:
filter(lambda k: Line2D.markers[k] != 'nothing', Line2D.markers)


Out[42]:
[0,
 1,
 2,
 3,
 4,
 u'D',
 6,
 7,
 u's',
 u'|',
 u'x',
 5,
 u'_',
 u'^',
 u'd',
 u'h',
 u'+',
 u'*',
 u',',
 u'o',
 u'.',
 u'1',
 u'p',
 u'3',
 u'2',
 u'4',
 u'H',
 u'v',
 u'8',
 u'<',
 u'>']

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]:
<matplotlib.text.Text at 0x13cfdaa90>

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]:
<matplotlib.text.Text at 0x13de03dd0>

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]:
<matplotlib.text.Text at 0x13e77c810>

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 [ ]: