1 from __future__
import print_function
8 from colorsys
import hls_to_rgb, rgb_to_hls
11 from matplotlib.font_manager
import FontProperties
12 from matplotlib._png
import read_png
13 from matplotlib.offsetbox
import OffsetImage
14 from matplotlib.offsetbox
import AnnotationBbox
20 FONT_PROPS_SUPTITLE = FontProperties(size=
"x-large", weight=
"bold", stretch=
"condensed")
21 FONT_PROPS_TITLE = FontProperties(size=
"large", weight=
"regular")
22 FONT_PROPS_AX_TITLE = FontProperties(size=
"x-large", weight=
"bold")
23 FONT_PROPS_TICK_LABEL = FontProperties(size=
"large", weight=
"bold")
28 """Just some Matplotlib settings.""" 29 matplotlib.rcParams[
"text.usetex"] =
False 30 matplotlib.rcParams[
"legend.numpoints"] = 1
31 matplotlib.rcParams[
"figure.figsize"] = (8., 6.)
32 matplotlib.rcParams[
"figure.dpi"] = 300
33 matplotlib.rcParams[
"savefig.dpi"] = matplotlib.rcParams[
"figure.dpi"]
34 matplotlib.rcParams[
"font.size"] = 10.8
35 matplotlib.rcParams[
"pdf.fonttype"] = 42
41 """Read logo from PNG file and add it to axes.""" 43 logo_data = read_png(logo_name)
44 fig_dpi = ax.get_figure().dpi
45 fig_size = ax.get_figure().get_size_inches()
47 zoom_factor = .1 / 1.2 * fig_dpi * fig_size[0] / np.shape(logo_data)[0]
49 logo_box = OffsetImage(logo_data, zoom=zoom_factor)
50 ann_box = AnnotationBbox(logo_box, [0., 1.],
52 xycoords=
"axes fraction",
53 boxcoords=
"offset points",
54 box_alignment=(0., 1.),
55 pad=0., frameon=
False)
56 ax.add_artist(ann_box)
77 "b^{-1}" :
"$\mathbf{b}^{-1}$",
78 "mb^{-1}" :
"$\mathbf{mb}^{-1}$",
79 "ub^{-1}" :
"$\mu\mathbf{b}^{-1}$",
80 "nb^{-1}" :
"$\mathbf{nb}^{-1}$",
81 "pb^{-1}" :
"$\mathbf{pb}^{-1}$",
82 "fb^{-1}" :
"$\mathbf{fb}^{-1}$",
83 "Hz/b" :
"$\mathbf{Hz/b}$",
84 "Hz/mb" :
"$\mathbf{Hz/mb}$",
85 "Hz/ub" :
"$\mathbf{Hz/}\mathbf{\mu}\mathbf{b}$",
86 "Hz/nb" :
"$\mathbf{Hz/nb}$",
87 "Hz/pb" :
"$\mathbf{Hz/pb}$",
88 "Hz/fb" :
"$\mathbf{Hz/fb}$" 91 res = latex_units[units_in]
99 """Takes a tuple (r, g, b) as input.""" 101 color_tmp = matplotlib.colors.colorConverter.to_rgb(color_in)
103 tmp = rgb_to_hls(*color_tmp)
104 color_out = hls_to_rgb(tmp[0], .7 * tmp[1], tmp[2])
112 """A bit of a cludge, but a simple way to store color choices.""" 122 ColorScheme.cms_blue = (0./255., 152./255., 212./255.)
125 ColorScheme.cms_orange = (241./255., 194./255., 40./255.)
128 ColorScheme.cms_blue_dark = (102./255., 153./255., 204./255.)
129 ColorScheme.cms_orange_dark = (255./255., 153./255., 0./255.)
138 ColorScheme.cms_red = (208./255., 0./255., 37./255.)
139 ColorScheme.cms_yellow = (255./255., 248./255., 0./255.)
140 ColorScheme.cms_purple = (125./255., 16./255., 123./255.)
141 ColorScheme.cms_green = (60./255., 177./255., 110./255.)
142 ColorScheme.cms_orange2 = (227./255., 136./255., 36./255.)
143 ColorScheme.cms_lightyellow = (255./255., 235./255., 215./255.)
170 tmp_name = self.name.lower()
171 if tmp_name ==
"greg":
185 elif tmp_name ==
"joe":
200 print(
"ERROR Unknown color scheme '%s'" % self.
name, file=sys.stderr)
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)
S & print(S &os, JobReport::InputFile const &f)