forked from rkp8000/seq_speak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisp.py
57 lines (38 loc) · 1.65 KB
/
disp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from copy import deepcopy
import numpy as np
import warnings
warnings.filterwarnings("ignore", category=UserWarning, module="matplotlib")
def set_font_size(ax, font_size, legend_font_size=None):
"""Set font_size of all axis text objects to specified value."""
texts = [ax.title, ax.xaxis.label, ax.yaxis.label] + \
ax.get_xticklabels() + ax.get_yticklabels()
for text in texts:
text.set_fontsize(font_size)
if ax.get_legend():
if not legend_font_size:
legend_font_size = font_size
for text in ax.get_legend().get_texts():
text.set_fontsize(legend_font_size)
def set_n_x_ticks(ax, n, x_min=None, x_max=None):
x_ticks = ax.get_xticks()
x_min = np.min(x_ticks) if x_min is None else x_min
x_max = np.max(x_ticks) if x_max is None else x_max
ax.set_xticks(np.linspace(x_min, x_max, n))
def set_n_y_ticks(ax, n, y_min=None, y_max=None):
y_ticks = ax.get_yticks()
y_min = np.min(y_ticks) if y_min is None else y_min
y_max = np.max(y_ticks) if y_max is None else y_max
ax.set_yticks(np.linspace(y_min, y_max, n))
def set_colors(ax, color):
"""Set colors on all parts of axis."""
ax.spines['bottom'].set_color(color)
ax.spines['top'].set_color(color)
ax.spines['left'].set_color(color)
ax.spines['right'].set_color(color)
ax.tick_params(axis='x', color=color)
ax.tick_params(axis='y', color=color)
for text in ax.get_xticklabels() + ax.get_yticklabels():
text.set_color(color)
ax.title.set_color(color)
ax.xaxis.label.set_color(color)
ax.yaxis.label.set_color(color)