-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotstyle.py
More file actions
365 lines (318 loc) · 15.6 KB
/
plotstyle.py
File metadata and controls
365 lines (318 loc) · 15.6 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# -*- coding: utf-8 -*-
from colors import default_color_cycler
class PlotStyle():
def __init__(self, singlecolumn, plotnumber, verticalplot, journal):
_width, _height = self.makesize(singlecolumn, plotnumber, verticalplot, journal)
acsparams = {'font.family': 'sans-serif',
'font.serif': ['Times', 'Computer Modern Roman'],
'font.sans-serif': ['Helvetica', 'Computer Modern Sans serif'],
'font.size': 9,
'text.usetex': True,
# To force LaTeX use Helvetica fonts.
'text.latex.preamble': [r'\usepackage{siunitx}',
r'\sisetup{detect-all}',
r'\usepackage{helvet}',
r'\usepackage[eulergreek,EULERGREEK]{sansmath}',
r'\sansmath'],
'axes.prop_cycle': default_color_cycler,
'axes.labelsize': 9.5,
'axes.linewidth': 1,
'figure.figsize': (_width, _height),
'figure.subplot.left': 0.125,
'figure.subplot.right': 0.95,
'figure.subplot.bottom': 0.1,
'figure.subplot.top': 0.95,
'savefig.dpi': 300,
'savefig.format': 'tiff',
'legend.fontsize': 8.5,
'legend.frameon': False,
'legend.numpoints': 1,
'legend.handlelength': 2,
'legend.scatterpoints': 1,
'legend.labelspacing': 0.5,
'legend.markerscale': 0.9,
'legend.handletextpad': 0.5, # pad between handle and text
'legend.borderaxespad': 0.5, # pad between legend and axes
'legend.borderpad': 0.5, # pad between legend and legend content
'legend.columnspacing': 1, # pad between each legend column
# 'text.fontsize' : 8,
'xtick.labelsize': 9,
'ytick.labelsize': 9,
'lines.linewidth': 1.1,
'lines.markersize': 4,
# 'lines.markeredgewidth': 0,
# 0 will make line-type markers, such as '+', 'x', invisible
}
rscparams = {'font.family': 'sans-serif',
'font.serif': ['Times', 'Computer Modern Roman'],
'font.sans-serif': ['Helvetica', 'Arial',
'Computer Modern Sans serif'],
'font.size': 8,
'text.usetex': True,
# To force LaTeX use Helvetica fonts.
'text.latex.preamble': [r'\usepackage{siunitx}',
r'\sisetup{detect-all}',
r'\usepackage{helvet}',
r'\usepackage[eulergreek,EULERGREEK]{sansmath}',
r'\sansmath'],
'axes.prop_cycle': default_color_cycler,
'axes.labelsize': 8,
'axes.linewidth': 1,
'figure.figsize': (_width, _height),
'figure.subplot.left': 0.125,
'figure.subplot.right': 0.95,
'figure.subplot.bottom': 0.1,
'figure.subplot.top': 0.95,
'savefig.dpi': 300,
'savefig.format': 'eps',
'legend.fontsize': 8,
'legend.frameon': False,
'legend.numpoints': 1,
'legend.handlelength': 2,
'legend.scatterpoints': 1,
'legend.labelspacing': 0.5,
'legend.markerscale': 0.9,
'legend.handletextpad': 0.5, # pad between handle and text
'legend.borderaxespad': 0.5, # pad between legend and axes
'legend.borderpad': 0.5, # pad between legend and legend content
'legend.columnspacing': 1, # pad between each legend column
# 'text.fontsize' : 7, # use font.size for Matplotlib 1.4.2+
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'lines.linewidth': 1,
'lines.markersize': 4,
# 'lines.markeredgewidth' : 0,
# 0 will make line-type markers, such as '+', 'x', invisible
}
elsevierparams = {'font.family': 'sans-serif',
'font.serif': ['Times', 'Computer Modern Roman'],
'font.sans-serif': ['Helvetica', 'Arial',
'Computer Modern Sans serif'],
'font.size': 8,
'text.usetex': True,
# To force LaTeX use Helvetica fonts.
'text.latex.preamble': [r'\usepackage{siunitx}',
r'\sisetup{detect-all}',
r'\usepackage{helvet}',
r'\usepackage[eulergreek,EULERGREEK]{sansmath}',
r'\sansmath'],
'axes.prop_cycle': default_color_cycler,
'axes.labelsize': 8,
'axes.linewidth': 1,
'figure.figsize': (_width, _height),
'figure.subplot.left': 0.125,
'figure.subplot.right': 0.95,
'figure.subplot.bottom': 0.1,
'figure.subplot.top': 0.95,
'savefig.dpi': 300,
'savefig.format': 'eps',
'legend.fontsize': 8,
'legend.frameon': False,
'legend.numpoints': 1,
'legend.handlelength': 2,
'legend.scatterpoints': 1,
'legend.labelspacing': 0.5,
'legend.markerscale': 0.9,
'legend.handletextpad': 0.5, # pad between handle and text
'legend.borderaxespad': 0.5, # pad between legend and axes
'legend.borderpad': 0.5, # pad between legend and legend content
'legend.columnspacing': 1, # pad between each legend column
# 'text.fontsize' : 7, # use font.size for Matplotlib 1.4.2+
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'lines.linewidth': 1,
'lines.markersize': 4,
# 'lines.markeredgewidth' : 0,
# 0 will make line-type markers, such as '+', 'x', invisible
}
webparams = {'font.family': 'sans-serif',
'font.serif': ['Bitstream Vera Serif', 'Computer Modern Roman'],
'font.sans-serif': ['Helvetica', 'Arial', 'Lucida Grande'],
'font.size': 7,
'font.weight': 'normal',
'text.usetex': True,
# To force LaTeX use Helvetica fonts.
'text.latex.preamble': [r'\usepackage{siunitx}',
r'\sisetup{detect-all}',
r'\usepackage{helvet}',
r'\usepackage[eulergreek,EULERGREEK]{sansmath}',
r'\sansmath'],
'axes.prop_cycle': default_color_cycler,
'axes.labelsize': 'medium',
'axes.labelweight': 'normal',
'axes.linewidth': 0.8,
'figure.figsize': (_width, _height),
'figure.subplot.left': 0.125,
'figure.subplot.right': 0.95,
'figure.subplot.bottom': 0.1,
'figure.subplot.top': 0.95,
'savefig.dpi': 150,
'savefig.format': 'png',
'legend.fontsize': 'small',
'legend.frameon': False,
'legend.numpoints': 1,
'legend.handlelength': 2,
'legend.scatterpoints': 1,
'legend.labelspacing': 0.5,
'legend.markerscale': 0.9,
'legend.handletextpad': 0.5, # pad between handle and text
'legend.borderaxespad': 0.5, # pad between legend and axes
# pad between legend and legend content
'legend.borderpad': 0.5,
# pad between each legend column
'legend.columnspacing': 1,
# 'text.fontsize' : 'medium',
'xtick.major.size': 3,
# 'xtick.minor.size': 2,
'xtick.major.width': 0.8,
# 'xtick.minor.width': 0.5,
'xtick.major.pad': 2,
# 'xtick.minor.pad': 4,
# 'xtick.color' : k,
'xtick.labelsize': 'medium',
# 'xtick.direction': 'in',
'ytick.major.size': 3,
# 'ytick.minor.size': 2,
'ytick.major.width': 0.8,
# 'ytick.minor.width': 0.5,
'ytick.major.pad': 2,
# 'ytick.minor.pad': 4,
# 'ytick.color': k,
'ytick.labelsize': 'medium',
# 'ytick.direction' : 'in',
'lines.linewidth': 0.8,
'lines.markersize': 3,
# 'lines.markeredgewidth' : 0,
# 0 will make line-type markers, such as '+', 'x', invisible
}
presparams = {'font.family': 'sans-serif',
'font.serif': ['Times', 'Computer Modern Roman'],
'font.sans-serif': ['Helvetica', 'Arial', 'Lucida Grande'],
'font.size': 12,
'font.weight': 'normal',
'text.usetex': True,
# To force LaTeX use Helvetica fonts.
'text.latex.preamble': [r'\usepackage{siunitx}',
r'\sisetup{detect-all}',
r'\usepackage{helvet}',
r'\usepackage[eulergreek,EULERGREEK]{sansmath}',
r'\sansmath'],
'axes.prop_cycle': default_color_cycler,
'axes.labelsize': 'medium',
'axes.labelweight': 'normal',
'axes.linewidth': 1.5,
'figure.figsize': (_width, _height),
'figure.subplot.left': 0.125,
'figure.subplot.right': 0.95,
'figure.subplot.bottom': 0.1,
'figure.subplot.top': 0.95,
'savefig.dpi': 300,
'savefig.format': 'pdf',
'legend.fontsize': 'small',
'legend.frameon': False,
'legend.numpoints': 1,
'legend.handlelength': 2,
'legend.scatterpoints': 1,
'legend.labelspacing': 0.5,
'legend.markerscale': 0.9,
'legend.handletextpad': 0.5, # pad between handle and text
'legend.borderaxespad': 0.5, # pad between legend and axes
'legend.borderpad': 0.5, # pad between legend and legend content
'legend.columnspacing': 1, # pad between each legend column
# 'text.fontsize': 'medium',
'xtick.major.size': 6,
# 'xtick.minor.size' : 2,
'xtick.major.width': 1.5,
# 'xtick.minor.width' : 0.5,
# 'xtick.major.pad' : 4,
# 'xtick.minor.pad' : 4,
# 'xtick.color' : k,
'xtick.labelsize': 'medium',
# 'xtick.direction' : 'in',
'ytick.major.size': 6,
# 'ytick.minor.size' : 2,
'ytick.major.width': 1.5,
# 'ytick.minor.width' : 0.5,
# 'ytick.major.pad' : 4,
# 'ytick.minor.pad' : 4,
# 'ytick.color' : k,
'ytick.labelsize': 'medium',
# 'ytick.direction' : 'in',
'lines.linewidth': 1.5,
'lines.markersize': 6,
# 'lines.markeredgewidth' : 0,
# 0 will make line-type markers, such as '+', 'x', invisible
}
if journal == "ACS":
self._params = acsparams
elif journal == "RSC":
self._params = rscparams
elif journal == "Elsevier":
self._params = elsevierparams
elif journal == "Web":
self._params = webparams
elif journal == "Presentation":
self._params = presparams
def get_params(self):
return self._params
def makesize(self, singlecolumn, plotnumber, verticalplot, journal):
# Constants from ACS Authour Guidelines.
if journal == "ACS":
width_single_column = 3.25
width_double_column = 7.00
elif journal == "RSC":
width_single_column = 3.26 # 8.3 cm
width_double_column = 6.73 # 17.1 cm
elif journal == "Elsevier":
width_single_column = 3.54
width_double_column = 7.48
elif journal == "Web":
_width_normal_px = 440
save_dpi = 150
width_normal = self.point2inch(_width_normal_px, save_dpi)
width_tiny = 0.5 * width_normal
width_small = 0.8 * width_normal
width_large = 1.2 * width_normal
width_large2 = 1.5 * width_normal
width_huge = 1.8 * width_normal
width_single_column, width_double_column = width_normal, width_normal
elif journal == "Presentation":
_width_full_pt = 1024 # Units in number of points (or dots)
_width_normal_pt = int(_width_full_pt / 3.0)
width_normal = self.point2inch(_width_normal_pt)
width_tiny = 0.5 * width_normal
width_small = 0.8 * width_normal
width_large = 1.2 * width_normal
width_large2 = 1.5 * width_normal
width_huge = 1.8 * width_normal
width_full = 0.9 * self.point2inch(_width_full_pt) # use 90% of presentation page.
width_single_column, width_double_column = width_normal, width_normal
if singlecolumn:
hwr = 0.8
if (plotnumber == 2) and verticalplot:
hwr = 1.5
if (plotnumber == 3) and verticalplot:
hwr = 2.2
if (plotnumber == 4) and verticalplot:
hwr = 2.6
else:
hwr = 0.5
if plotnumber == 2:
hwr = 0.46
if plotnumber == 3:
hwr = 0.3
if plotnumber == 4:
hwr = 0.7
height_width_ratio = hwr * 1.1 # = height / width
if singlecolumn:
_width = width_single_column
_height = width_single_column * height_width_ratio
if plotnumber == 4 and not verticalplot:
_width = 2*_width
_height = 2*_height
else:
_width = width_double_column
_height = width_double_column * height_width_ratio
return _width, _height
def point2inch(self, npt, dpi=72.0):
return 1.0 * npt / dpi