comparison tools/myTools/bin/sfa/plot/table_batch.py @ 1:7e5c71b2e71f draft default tip

Uploaded
author laurenmarazzi
date Wed, 22 Dec 2021 16:00:34 +0000
parents
children
comparison
equal deleted inserted replaced
0:f24d4892aaed 1:7e5c71b2e71f
1 # -*- coding: utf-8 -*-
2
3 import matplotlib.pyplot as plt
4 import matplotlib.gridspec as gridspec
5
6 from .tableaxis import ResultTableAxis
7 from .table_condition import ConditionTable
8
9
10 class BatchResultTable(ConditionTable):
11
12 def __init__(self, data, cons, *args, **kwargs):
13 # Set references for data objects
14 self._dfe = data.df_exp # DataFrame of experiment results
15 self._dfr = cons # DataFrame of consensus between exp. and sim.
16 super().__init__(data.df_conds, *args, **kwargs)
17 # end of def __init__
18
19 def _parse_kwargs(self, **kwargs):
20 """Parse the keyword arguments.
21 """
22 self._dim = kwargs.get('dim', (1, 2))
23 self._wspace = kwargs.get('wspace', 0.05)
24 self._hspace = kwargs.get('hspace', 0)
25
26 ncols_conds = self._dfc.shape[1]
27 ncols_res = self._dfr.shape[1]
28 self._width_ratios = kwargs.get('width_ratios', [ncols_conds,
29 ncols_res])
30 self._height_ratios = kwargs.get('height_ratios', [1])
31
32 default_position = {'condition': (0, 0), 'result': (0, 1), }
33 self._axes_position = kwargs.get('axes_position',
34 default_position)
35
36 def _create_axes(self):
37 self._axes = {}
38 pos = self._axes_position['condition']
39 ax_conds = self._fig.add_subplot(self._gridspec[pos[0], pos[1]])
40 self._axes['condition'] = ax_conds
41
42 pos = self._axes_position['result']
43 ax_res = self._fig.add_subplot(self._gridspec[pos[0], pos[1]])
44 self._axes['result'] = ax_res
45
46 for ax in self._axes.values():
47 ax.grid(b=False)
48 ax.set_frame_on(False)
49 ax.invert_yaxis()
50 ax.xaxis.tick_top()
51
52 def _create_tables(self):
53 super()._create_tables()
54 tb = ResultTableAxis(self._axes['result'],
55 self._dfr,
56 self._dfe,
57 self._colors)
58 tb.fontsize = 4
59 tb.linewidth = 0.5
60 self._tables.append(tb)
61
62 def _set_colors(self, colors):
63 super()._set_colors(colors)
64 self._set_default_color('result_up_cell', '#35FF50') # Green
65 self._set_default_color('result_dn_cell', '#FF0000') # Red
66 self._set_default_color('result_up_text', 'black')
67 self._set_default_color('result_dn_text', 'white')
68
69 def _add_labels(self):
70 super()._add_labels()
71
72 # The second table, which is result DataFrame, adds
73 # column labels only.
74 tb = self._tables[1]
75 tb.add_column_labels()