forked from phayne/planet-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prettyPlots.py
46 lines (37 loc) · 981 Bytes
/
prettyPlots.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
"""
=============
Pretty Plots
=============
This module provides methods for making prettier plots,
with custom annotation
KNOWN ISSUE: Incompatible w/ pandas
Author: Paul O. Hayne
"""
import matplotlib
import numpy as np
rcParams = matplotlib.rcParams
rc = matplotlib.rc
# Set overall style of plots:
# Thicker lines, larger text, LaTeX rendering
def setStyle():
setFont(16)
rc('lines', linewidth=2, markersize=8)
rc('axes', titlesize=22, labelsize=20)
rc('xtick', labelsize=18)
rc('ytick', labelsize=18)
# Font settings
def setFont(font_size):
font = {'family' : 'serif',
'size' : font_size}
rc('font', **font)
rc('text', usetex=True)
#####################
# degreeLabelFormat #
#####################
# Format text with degree symbol
@np.vectorize
def degreeLabelFormat(x):
if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
return r"$%0.0f^\circ$" % x
else:
return "%0.0f\u00b0" % x