In [1]:
import pandas as pd
from pandas import *
import matplotlib.pyplot as plt
%matplotlib inline
from ggplot import *
from numpy import random
plt.style.use('ggplot')
In [11]:
data = pd.read_csv("./annotated/fig4_table.csv", header=None)
data.columns = ['A','B','C','D','E', 'F', 'G']
data
Out[11]:
A
B
C
D
E
F
G
0
3b
0
-2592702.947982
0.000000
99
16
No Sampling
1
3b
0
-2592702.947982
0.000000
99
16
One-term
2
3b
0
-2592702.947982
0.000000
43
97
Two-term
3
5b
1
-2595844.069090
3141.121108
99
16
No Sampling
4
5b
1
-2595844.069090
3141.121108
99
16
One-term
5
5b
1
-2595844.069090
3141.121108
43
97
Two-term
6
3b
2
-2598386.660000
5683.712018
61
61
No Sampling
7
3b
2
-2598386.660000
5683.712018
62
60
One-term
8
3b
2
-2598386.660000
5683.712018
61
61
Two-term
9
2b
3
-2598423.780000
5720.832018
61
61
No Sampling
10
2b
3
-2598423.780000
5720.832018
62
61
One-term
11
2b
3
-2598423.780000
5720.832018
61
61
Two-term
12
8b
1
-2598424.272000
5721.324018
61
61
No Sampling
13
8b
1
-2598424.272000
5721.324018
62
60
One-term
14
8b
1
-2598424.272000
5721.324018
61
61
Two-term
15
4b
2
-2598487.073000
5784.125018
61
61
No Sampling
16
4b
2
-2598487.073000
5784.125018
61
61
One-term
17
4b
2
-2598487.073000
5784.125018
61
61
Two-term
18
7b
3
-2598498.457000
5795.509018
61
61
No Sampling
19
7b
3
-2598498.457000
5795.509018
62
60
One-term
20
7b
3
-2598498.457000
5795.509018
61
61
Two-term
21
PB
4
-2598508.186000
5805.238018
61
61
No Sampling
22
PB
4
-2598508.186000
5805.238018
62
60
One-term
23
PB
4
-2598508.186000
5805.238018
61
61
Two-term
24
5b
2
-2598572.819000
5869.871018
61
61
No Sampling
25
5b
2
-2598572.819000
5869.871018
61
61
One-term
26
5b
2
-2598572.819000
5869.871018
61
61
Two-term
27
9b
3
-2598851.666000
6148.718018
61
61
No Sampling
28
9b
3
-2598851.666000
6148.718018
61
61
One-term
29
9b
3
-2598851.666000
6148.718018
61
61
Two-term
30
9b
4
-2599726.211974
7023.263992
99
16
No Sampling
31
9b
4
-2599726.211974
7023.263992
99
16
One-term
32
9b
4
-2599726.211974
7023.263992
43
97
Two-term
33
6b
5
-2600834.749000
8131.801018
61
61
No Sampling
34
6b
5
-2600834.749000
8131.801018
62
59
One-term
35
6b
5
-2600834.749000
8131.801018
61
61
Two-term
36
7b
3
-2600891.787168
8188.839186
99
16
No Sampling
37
7b
3
-2600891.787168
8188.839186
99
16
One-term
38
7b
3
-2600891.787168
8188.839186
43
97
Two-term
39
2b
4
-2601313.228467
8610.280485
99
16
No Sampling
40
2b
4
-2601313.228467
8610.280485
99
16
One-term
41
2b
4
-2601313.228467
8610.280485
43
97
Two-term
42
4b
5
-2601594.728666
8891.780684
99
16
No Sampling
43
4b
5
-2601594.728666
8891.780684
99
16
One-term
44
4b
5
-2601594.728666
8891.780684
43
97
Two-term
45
8b
6
-2601829.570443
9126.622461
99
16
No Sampling
46
8b
6
-2601829.570443
9126.622461
99
16
One-term
47
8b
6
-2601829.570443
9126.622461
43
97
Two-term
48
10b
4
-2602803.781000
10100.833018
61
61
No Sampling
49
10b
4
-2602803.781000
10100.833018
62
60
One-term
50
10b
4
-2602803.781000
10100.833018
61
61
Two-term
51
6b
5
-2605097.638018
12394.690036
99
16
No Sampling
52
6b
5
-2605097.638018
12394.690036
99
16
One-term
53
6b
5
-2605097.638018
12394.690036
43
97
Two-term
54
10b
6
-2639204.495699
46501.547717
99
16
No Sampling
55
10b
6
-2639204.495699
46501.547717
99
16
One-term
56
10b
6
-2639204.495699
46501.547717
43
97
Two-term
57
PB
7
-2676499.387000
83796.439018
46
88
No Sampling
58
PB
7
-2676499.387000
83796.439018
43
94
One-term
59
PB
7
-2676499.387000
83796.439018
47
89
Two-term
In [12]:
data=data.drop('A',axis=1)
data=data.drop('C',axis=1)
data=data.drop('E',axis=1)
data=data.drop('B',axis=1)
data['D'] = data['D'].astype(int)
table = pivot_table(data, index=['D'], columns=['G'])
table
Out[12]:
F
G
No Sampling
One-term
Two-term
D
0
16
16
97
3141
16
16
97
5683
61
60
61
5720
61
61
61
5721
61
60
61
5784
61
61
61
5795
61
60
61
5805
61
60
61
5869
61
61
61
6148
61
61
61
7023
16
16
97
8131
61
59
61
8188
16
16
97
8610
16
16
97
8891
16
16
97
9126
16
16
97
10100
61
60
61
12394
16
16
97
46501
16
16
97
83796
88
94
89
In [14]:
table.plot(kind='bar',secondary_x=True, legend=False, width=.7)
plt.tight_layout()
plt.savefig('hist.svg', bbox_inches='tight', dpi=300)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-14-80bb76c42781> in <module>()
----> 1 table.plot(kind='bar',secondary_x=True, legend=False, width=.7)
2 ax2 = ax1.twiny()
3 plt.tight_layout()
4 plt.savefig('hist.svg', bbox_inches='tight', dpi=300)
/home/april/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in plot_frame(frame, x, y, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, style, title, xlim, ylim, logx, logy, xticks, yticks, kind, sort_columns, fontsize, secondary_y, **kwds)
2156 secondary_y=secondary_y, **kwds)
2157
-> 2158 plot_obj.generate()
2159 plot_obj.draw()
2160 if subplots:
/home/april/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in generate(self)
900 self._compute_plot_data()
901 self._setup_subplots()
--> 902 self._make_plot()
903 self._add_table()
904 self._make_legend()
/home/april/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _make_plot(self)
1874 w = self.bar_width / K
1875 rect = bar_f(ax, self.ax_pos + (i + 1.5) * w, y, w,
-> 1876 start=start, label=label, **kwds)
1877
1878 self._add_legend_handle(rect, label, index=i)
/home/april/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in f(ax, x, y, w, start, **kwds)
1813 if self.kind == 'bar':
1814 def f(ax, x, y, w, start=None, **kwds):
-> 1815 return ax.bar(x, y, w, bottom=start,log=self.log, **kwds)
1816 elif self.kind == 'barh':
1817 def f(ax, x, y, w, start=None, log=self.log, **kwds):
/home/april/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in bar(self, left, height, width, bottom, **kwargs)
2041 label='_nolegend_'
2042 )
-> 2043 r.update(kwargs)
2044 r.get_path()._interpolation_steps = 100
2045 #print r.get_label(), label, 'label' in kwargs
/home/april/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in update(self, props)
755 func = getattr(self, 'set_' + k, None)
756 if func is None or not six.callable(func):
--> 757 raise AttributeError('Unknown property %s' % k)
758 func(v)
759 changed = True
AttributeError: Unknown property secondary_x
In [ ]:
Content source: wrightaprilm/squamates
Similar notebooks: