7 from colorsys
import hls_to_rgb, rgb_to_hls
10 from matplotlib.font_manager
import FontProperties
11 from matplotlib._png
import read_png
12 from matplotlib.offsetbox
import OffsetImage
13 from matplotlib.offsetbox
import AnnotationBbox
19 FONT_PROPS_SUPTITLE = FontProperties(size=
"x-large", weight=
"bold", stretch=
"condensed")
20 FONT_PROPS_TITLE = FontProperties(size=
"large", weight=
"regular")
21 FONT_PROPS_AX_TITLE = FontProperties(size=
"x-large", weight=
"bold")
22 FONT_PROPS_TICK_LABEL = FontProperties(size=
"large", weight=
"bold")
27 """Just some Matplotlib settings."""
28 matplotlib.rcParams[
"text.usetex"] =
False
29 matplotlib.rcParams[
"legend.numpoints"] = 1
30 matplotlib.rcParams[
"figure.figsize"] = (8., 6.)
31 matplotlib.rcParams[
"figure.dpi"] = 300
32 matplotlib.rcParams[
"savefig.dpi"] = matplotlib.rcParams[
"figure.dpi"]
33 matplotlib.rcParams[
"font.size"] = 10.8
34 matplotlib.rcParams[
"pdf.fonttype"] = 42
40 """Read logo from PNG file and add it to axes."""
42 logo_data = read_png(logo_name)
43 fig_dpi = ax.get_figure().dpi
44 fig_size = ax.get_figure().get_size_inches()
46 zoom_factor = .1 / 1.2 * fig_dpi * fig_size[0] / np.shape(logo_data)[0]
48 logo_box = OffsetImage(logo_data, zoom=zoom_factor)
49 ann_box = AnnotationBbox(logo_box, [0., 1.],
51 xycoords=
"axes fraction",
52 boxcoords=
"offset points",
53 box_alignment=(0., 1.),
54 pad=0., frameon=
False)
55 ax.add_artist(ann_box)
76 "b^{-1}" :
"$\mathbf{b}^{-1}$",
77 "mb^{-1}" :
"$\mathbf{mb}^{-1}$",
78 "ub^{-1}" :
"$\mu\mathbf{b}^{-1}$",
79 "nb^{-1}" :
"$\mathbf{nb}^{-1}$",
80 "pb^{-1}" :
"$\mathbf{pb}^{-1}$",
81 "fb^{-1}" :
"$\mathbf{fb}^{-1}$",
82 "Hz/b" :
"$\mathbf{Hz/b}$",
83 "Hz/mb" :
"$\mathbf{Hz/mb}$",
84 "Hz/ub" :
"$\mathbf{Hz/}\mathbf{\mu}\mathbf{b}$",
85 "Hz/nb" :
"$\mathbf{Hz/nb}$",
86 "Hz/pb" :
"$\mathbf{Hz/pb}$",
87 "Hz/fb" :
"$\mathbf{Hz/fb}$"
90 res = latex_units[units_in]
98 """Takes a tuple (r, g, b) as input."""
100 color_tmp = matplotlib.colors.colorConverter.to_rgb(color_in)
102 tmp = rgb_to_hls(*color_tmp)
103 color_out = hls_to_rgb(tmp[0], .7 * tmp[1], tmp[2])
111 """A bit of a cludge, but a simple way to store color choices."""
121 ColorScheme.cms_blue = (0./255., 152./255., 212./255.)
124 ColorScheme.cms_orange = (241./255., 194./255., 40./255.)
127 ColorScheme.cms_blue_dark = (102./255., 153./255., 204./255.)
128 ColorScheme.cms_orange_dark = (255./255., 153./255., 0./255.)
137 ColorScheme.cms_red = (208./255., 0./255., 37./255.)
138 ColorScheme.cms_yellow = (255./255., 248./255., 0./255.)
139 ColorScheme.cms_purple = (125./255., 16./255., 123./255.)
140 ColorScheme.cms_green = (60./255., 177./255., 110./255.)
141 ColorScheme.cms_orange2 = (227./255., 136./255., 36./255.)
142 ColorScheme.cms_lightyellow = (255./255., 235./255., 215./255.)
169 tmp_name = self.name.lower()
170 if tmp_name ==
"greg":
184 elif tmp_name ==
"joe":
199 print >> sys.stderr, \
200 "ERROR Unknown color scheme '%s'" % self.
name
205 logo_path = os.path.realpath(os.path.dirname(__file__))
216 """Little helper to save plots in various formats."""
220 assert len(fig.axes) == 2
221 assert len(fig.axes[0].artists) == 1
222 assert file_name_base.find(
".") < 0
226 fig.savefig(
"%s.png" % file_name_base)
230 tmp_annbox = fig.axes[0].artists[0]
231 tmp_offsetbox = tmp_annbox.offsetbox
233 tmp_offsetbox.set_zoom(tmp_offsetbox.get_zoom() * 72. / fig_dpi)
234 tmp = tmp_annbox.xytext
235 tmp_annbox.xytext = (tmp[0] + 1., tmp[1] - 1.)
236 fig.savefig(
"%s.pdf" % file_name_base, dpi=600)