Skip to content

Commit 9dbb893

Browse files
Naawwwmurd0
authored andcommitted
Nhsd colours (#106)
* Create nhsd_colours.py Have added the code and commented to Numpy standard. * Update nhsd_colours.py Ran through a pep-8 checker - adjusted to match pep-8 standard. * Update requirements.txt Adding seaborn requirement, for nhsd_colours
1 parent 8045911 commit 9dbb893

File tree

2 files changed

+103
-1
lines changed

2 files changed

+103
-1
lines changed

codonPython/nhsd_colours.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import seaborn as sns
2+
import random
3+
4+
5+
def nhsd_colours():
6+
'''Returns a dictionary full of the different official NHSD colours from the
7+
style guide:
8+
https://digital.nhs.uk/about-nhs-digital/corporate-information-and-documents/nhs-digital-style-guidelines/how-we-look/colour-palette
9+
10+
Parameters
11+
----------
12+
None
13+
14+
Returns
15+
--------
16+
colour_dict : dict (Python dictionary)
17+
A dictionary containing sets of official NHS Digital branding colours
18+
(Hexidecimal format) and fonts.
19+
'''
20+
21+
nhsd_chart_colours = ['#005EB8', '#71CCEF', '#84919C',
22+
'#003087', '#D0D5D6', ]
23+
nhsd_chart_background = {'chart_grey_3': '#F8F8F8', 'white': '#FFFFFF'}
24+
nhsd_core_colours = {'white': '#ffffff',
25+
'white_tints': ['#f9fafb', '#f3f5f6', '#edeff1',
26+
'#def2e5'],
27+
'nhs_blue': '#005eb8',
28+
'blue_tints': ['#337EC6', '#ACCAE8', '#D4E4F3',
29+
'#E6EFF8'],
30+
'nhs_dark_grey': '#425563',
31+
'grey_tints': ['#687784', '#98A4AD', '#B3BBC1',
32+
'#DFE2E5', '#EDEFF1', '#F3F5F6',
33+
'#F9FAFB'],
34+
'nhs_mild_grey': '#768692',
35+
'nhs_warm_yellow': '#FFB81C',
36+
'warm_yellow_tints': ['#FFE8B4', '#FFF1CC', '#FFF8E8']
37+
}
38+
nhsd_font = ['Frutiger Light', 'Frutiger Roman']
39+
nhsd_font_backup = ['Arial']
40+
colour_dict = {'chart': nhsd_chart_colours,
41+
'chart_background': nhsd_chart_background,
42+
'core': nhsd_core_colours,
43+
'font': nhsd_font,
44+
'font_backup': nhsd_font_backup}
45+
return colour_dict
46+
47+
48+
def nhsd_seaborn_style():
49+
'''Sets the seaborn style to be inline with NHSD guidlines. This means your
50+
graphs in Seaborn, or in Matplotlib will come out looking as per the NHSD
51+
style guide. Simply run this function.
52+
53+
Parameters
54+
----------
55+
None
56+
57+
Returns
58+
----------
59+
None'''
60+
nhs_colours = nhsd_colours()
61+
chart_background = nhs_colours['chart_background']
62+
font_backup = nhs_colours['font_backup']
63+
chart_colours = nhs_colours['chart']
64+
65+
additional_colours = (nhsd_colours()['core']['blue_tints'] +
66+
nhsd_colours()['core']['grey_tints'] +
67+
nhsd_colours()['core']['nhs_warm_yellow'] +
68+
nhsd_colours()['core']['warm_yellow_tints'])
69+
random.shuffle(additional_colours)
70+
nhs_colours = chart_colours + additional_colours
71+
72+
sns.set_palette(nhs_colours)
73+
74+
seaborn_style_dict = {'axes.axisbelow': True,
75+
'axes.edgecolor': '.8',
76+
'axes.facecolor': chart_background['chart_grey_3'],
77+
'axes.grid': True,
78+
'axes.labelcolor': '.15',
79+
'axes.spines.bottom': False, # no spines
80+
'axes.spines.left': False, # no spines
81+
'axes.spines.right': False, # no spines
82+
'axes.spines.top': False, # no spines
83+
'figure.facecolor': chart_background['chart_grey_3'],
84+
'font.family': ['sans-serif'],
85+
'font.sans-serif': font_backup,
86+
'grid.color': '.8',
87+
'grid.linestyle': '-',
88+
'image.cmap': 'rocket',
89+
'lines.solid_capstyle': 'round',
90+
'patch.edgecolor': 'w',
91+
'patch.force_edgecolor': True,
92+
'text.color': '.15',
93+
'xtick.bottom': False,
94+
'xtick.color': '.15',
95+
'xtick.direction': 'out',
96+
'xtick.top': False,
97+
'ytick.color': '.15',
98+
'ytick.direction': 'out',
99+
'ytick.left': False,
100+
'ytick.right': False}
101+
sns.set_style('whitegrid', seaborn_style_dict)

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ scipy>=0.19.0
33
pandas>=0.24.0
44
sqlalchemy>=1.3.5
55
scikit-learn>=0.21.2
6-
statsmodels>=0.10.0
6+
statsmodels>=0.10.0
7+
seaborn>=0.9.0

0 commit comments

Comments
 (0)