aptapy 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aptapy/__init__.py +44 -0
- aptapy/_version.py +1 -0
- aptapy/modeling.py +515 -0
- aptapy/plotting.py +486 -0
- aptapy/py.typed +0 -0
- aptapy/typing_.py +23 -0
- aptapy-0.1.1.dist-info/METADATA +702 -0
- aptapy-0.1.1.dist-info/RECORD +10 -0
- aptapy-0.1.1.dist-info/WHEEL +4 -0
- aptapy-0.1.1.dist-info/licenses/LICENSE +674 -0
aptapy/plotting.py
ADDED
@@ -0,0 +1,486 @@
|
|
1
|
+
# Copyright (C) 2025 Luca Baldini (luca.baldini@pi.infn.it)
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
"""Plotting facilities.
|
17
|
+
"""
|
18
|
+
|
19
|
+
from typing import Any
|
20
|
+
|
21
|
+
import matplotlib
|
22
|
+
import matplotlib.pyplot as plt # noqa: F401 pylint: disable=unused-import
|
23
|
+
from cycler import cycler
|
24
|
+
from loguru import logger
|
25
|
+
|
26
|
+
DEFAULT_FIGURE_WIDTH = 8.
|
27
|
+
DEFAULT_FIGURE_HEIGHT = 6.
|
28
|
+
DEFAULT_FIGURE_SIZE = (DEFAULT_FIGURE_WIDTH, DEFAULT_FIGURE_HEIGHT)
|
29
|
+
DEFAULT_COLOR_CYCLE = [
|
30
|
+
'#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b',
|
31
|
+
'#e377c2', '#7f7f7f', '#bcbd22', '#17becf'
|
32
|
+
]
|
33
|
+
|
34
|
+
|
35
|
+
def _set(key: str, value: Any):
|
36
|
+
"""Set the value for a single matplotlib parameter.
|
37
|
+
|
38
|
+
The actual command is encapsulated into a try except block because this
|
39
|
+
is intended to work across different matplotlib versions. If a setting
|
40
|
+
cannot be applied for whatever reason, this will happily move on.
|
41
|
+
"""
|
42
|
+
try:
|
43
|
+
matplotlib.rcParams[key] = value
|
44
|
+
except KeyError:
|
45
|
+
logger.warning(f'Unknown matplotlib rc param {key}, skipping...')
|
46
|
+
except ValueError as exception:
|
47
|
+
logger.warning(f'{exception}, skipping...')
|
48
|
+
|
49
|
+
|
50
|
+
def configure() -> None:
|
51
|
+
"""See https://matplotlib.org/stable/users/explain/customizing.html for more
|
52
|
+
information.
|
53
|
+
"""
|
54
|
+
# pylint:disable=too-many-statements
|
55
|
+
|
56
|
+
# Backends
|
57
|
+
_set('interactive', False)
|
58
|
+
_set('timezone', 'UTC')
|
59
|
+
|
60
|
+
# Lines
|
61
|
+
# See https://matplotlib.org/stable/api/artist_api.html#module-matplotlib.lines
|
62
|
+
_set('lines.linewidth', 1.5) # line width in points
|
63
|
+
_set('lines.linestyle', '-') # solid line
|
64
|
+
_set('lines.color', 'C0') # has no affect on plot(); see axes.prop_cycle
|
65
|
+
_set('lines.marker', 'None') # the default marker
|
66
|
+
_set('lines.markerfacecolor', 'auto') # the default marker face color
|
67
|
+
_set('lines.markeredgecolor', 'auto') # the default marker edge color
|
68
|
+
_set('lines.markeredgewidth', 1.0) # the line width around the marker symbol
|
69
|
+
_set('lines.markersize', 6) # marker size, in points
|
70
|
+
_set('lines.dash_joinstyle', 'round') # {miter, round, bevel}
|
71
|
+
_set('lines.dash_capstyle', 'butt') # {butt, round, projecting}
|
72
|
+
_set('lines.solid_joinstyle', 'round') # {miter, round, bevel}
|
73
|
+
_set('lines.solid_capstyle', 'projecting') # {butt, round, projecting}
|
74
|
+
_set('lines.antialiased', True) # render lines in antialiased (no jaggies)
|
75
|
+
# The three standard dash patterns. These are scaled by the linewidth.
|
76
|
+
_set('lines.dashed_pattern', (3.7, 1.6))
|
77
|
+
_set('lines.dashdot_pattern', (6.4, 1.6, 1, 1.6))
|
78
|
+
_set('lines.dotted_pattern', (1, 1.65))
|
79
|
+
_set('lines.scale_dashes', True)
|
80
|
+
_set('markers.fillstyle', 'full') # {full, left, right, bottom, top, none}
|
81
|
+
_set('pcolor.shading', 'auto')
|
82
|
+
# Whether to snap the mesh to pixel boundaries. This is provided solely to allow
|
83
|
+
# old test images to remain unchanged. Set to False to obtain the previous behavior.
|
84
|
+
_set('pcolormesh.snap', True)
|
85
|
+
|
86
|
+
# Patches are graphical objects that fill 2D space, like polygons or circles.
|
87
|
+
# See https://matplotlib.org/stable/api/artist_api.html#module-matplotlib.patches
|
88
|
+
_set('patch.linewidth', 1.0) # edge width in points.
|
89
|
+
_set('patch.facecolor', 'C0')
|
90
|
+
# By default, Patches and Collections do not draw edges. This value is only used
|
91
|
+
# if facecolor is "none" (an Artist without facecolor and edgecolor would be
|
92
|
+
# invisible) or if patch.force_edgecolor is True.
|
93
|
+
_set('patch.edgecolor', 'black')
|
94
|
+
# By default, Patches and Collections do not draw edges. Set this to True to draw
|
95
|
+
# edges with patch.edgedcolor as the default edgecolor. This is mainly relevant
|
96
|
+
# for styles.
|
97
|
+
_set('patch.force_edgecolor', False)
|
98
|
+
_set('patch.antialiased', True) # render patches in antialiased (no jaggies)
|
99
|
+
|
100
|
+
# Hatches
|
101
|
+
_set('hatch.color', 'black')
|
102
|
+
_set('hatch.linewidth', 1.0)
|
103
|
+
|
104
|
+
# Boxplot---we don't really use these much, but you never know...
|
105
|
+
_set('boxplot.notch', False)
|
106
|
+
_set('boxplot.vertical', True)
|
107
|
+
_set('boxplot.whiskers', 1.5)
|
108
|
+
_set('boxplot.bootstrap', None)
|
109
|
+
_set('boxplot.patchartist', False)
|
110
|
+
_set('boxplot.showmeans', False)
|
111
|
+
_set('boxplot.showcaps', True)
|
112
|
+
_set('boxplot.showbox', True)
|
113
|
+
_set('boxplot.showfliers', True)
|
114
|
+
_set('boxplot.meanline', False)
|
115
|
+
_set('boxplot.flierprops.color', 'black')
|
116
|
+
_set('boxplot.flierprops.marker', 'o')
|
117
|
+
_set('boxplot.flierprops.markerfacecolor', 'none')
|
118
|
+
_set('boxplot.flierprops.markeredgecolor', 'black')
|
119
|
+
_set('boxplot.flierprops.markeredgewidth', 1.0)
|
120
|
+
_set('boxplot.flierprops.markersize', 6)
|
121
|
+
_set('boxplot.flierprops.linestyle', 'none')
|
122
|
+
_set('boxplot.flierprops.linewidth', 1.0)
|
123
|
+
_set('boxplot.boxprops.color', 'black')
|
124
|
+
_set('boxplot.boxprops.linewidth', 1.0)
|
125
|
+
_set('boxplot.boxprops.linestyle', '-')
|
126
|
+
_set('boxplot.whiskerprops.color', 'black')
|
127
|
+
_set('boxplot.whiskerprops.linewidth', 1.0)
|
128
|
+
_set('boxplot.whiskerprops.linestyle', '-')
|
129
|
+
_set('boxplot.capprops.color', 'black')
|
130
|
+
_set('boxplot.capprops.linewidth', 1.0)
|
131
|
+
_set('boxplot.capprops.linestyle', '-')
|
132
|
+
_set('boxplot.medianprops.color', 'C1')
|
133
|
+
_set('boxplot.medianprops.linewidth', 1.0)
|
134
|
+
_set('boxplot.medianprops.linestyle', '-')
|
135
|
+
_set('boxplot.meanprops.color', 'C2')
|
136
|
+
_set('boxplot.meanprops.marker', '^')
|
137
|
+
_set('boxplot.meanprops.markerfacecolor', 'C2')
|
138
|
+
_set('boxplot.meanprops.markeredgecolor', 'C2')
|
139
|
+
_set('boxplot.meanprops.markersize', 6)
|
140
|
+
_set('boxplot.meanprops.linestyle', '--')
|
141
|
+
_set('boxplot.meanprops.linewidth', 1.0)
|
142
|
+
|
143
|
+
# The font properties used by `text.Text`.
|
144
|
+
# See https://matplotlib.org/stable/api/font_manager_api.html
|
145
|
+
# Note that for font.serif, font.sans-serif, and font.monospace, the first element
|
146
|
+
# of the list (a DejaVu font) will always be used because DejaVu is shipped with
|
147
|
+
# Matplotlib and is thus guaranteed to be available.
|
148
|
+
_set('font.family', 'sans-serif')
|
149
|
+
_set('font.style', 'normal') # {normal (or roman), italic, oblique}
|
150
|
+
_set('font.variant', 'normal') # {normal, small-caps}
|
151
|
+
# The font.weight property has effectively 13 values: normal, bold, bolder, lighter,
|
152
|
+
# 100, 200, 300, ..., 900. Normal is the same as 400, and bold is 700. bolder and
|
153
|
+
# lighter are relative values with respect to the current weight.
|
154
|
+
_set('font.weight', 'normal')
|
155
|
+
_set('font.stretch', 'normal') # Currently not implemented.
|
156
|
+
# The font.size property is the default font size for text, given in points. 10 pt
|
157
|
+
# is the standard value. Special text sizes can be defined relative to font.size,
|
158
|
+
# using the following values: xx-small, x-small, small, medium, large, x-large,
|
159
|
+
# xx-large, larger, or smaller
|
160
|
+
_set('font.size', 14.0)
|
161
|
+
|
162
|
+
## The text properties used by `text.Text`.
|
163
|
+
## See https://matplotlib.org/stable/api/artist_api.html#module-matplotlib.text
|
164
|
+
_set('text.color', 'black')
|
165
|
+
# FreeType hinting flag {default, no_autohint, force_autohint, no_hinting}
|
166
|
+
_set('text.hinting', 'force_autohint')
|
167
|
+
# Specifies the amount of softness for hinting in the horizontal direction.
|
168
|
+
# A value of 1 will hint to full pixels. A value of 2 will hint to half pixels etc.
|
169
|
+
_set('text.hinting_factor', 8)
|
170
|
+
# Specifies the scaling factor for kerning values. This is provided solely to
|
171
|
+
# allow old test images to remain unchanged. Set to 6 to obtain previous behavior.
|
172
|
+
# Values other than 0 or 6 have no defined meaning.
|
173
|
+
_set('text.kerning_factor', 0)
|
174
|
+
_set('text.antialiased', True) # This only affects raster outputs.
|
175
|
+
# Use mathtext if there is an even number of unescaped dollar signs.
|
176
|
+
_set('text.parse_math', True)
|
177
|
+
|
178
|
+
# LaTeX
|
179
|
+
# See https://matplotlib.org/stable/users/explain/text/usetex.html
|
180
|
+
_set('text.usetex', False) # use latex for all text handling.
|
181
|
+
# Font set can be {dejavusans, dejavuserif, cm, stixsans, custom}, where
|
182
|
+
# "custom" is defined by the mathtext.bf, .cal, .it, ..., settings which map
|
183
|
+
# a TeX font name to a fontconfig font pattern.
|
184
|
+
_set('mathtext.fontset', 'dejavusans')
|
185
|
+
_set('mathtext.fallback', 'cm')
|
186
|
+
_set('mathtext.default', 'it')
|
187
|
+
|
188
|
+
# Axes
|
189
|
+
# See https://matplotlib.org/stable/api/axes_api.html#module-matplotlib.axes
|
190
|
+
_set('axes.facecolor', 'white') # axes background color
|
191
|
+
_set('axes.edgecolor', 'black') # axes edge color
|
192
|
+
_set('axes.linewidth', 1.2) # edge line width
|
193
|
+
_set('axes.grid', True) # display grid or not
|
194
|
+
_set('axes.grid.axis', 'both') # which axis the grid should apply to
|
195
|
+
_set('axes.grid.which', 'major') # grid lines at {major, minor, both} ticks
|
196
|
+
_set('axes.titlelocation', 'center') # alignment of the title: {left, right, center}
|
197
|
+
_set('axes.titlesize', 'large') # font size of the axes title
|
198
|
+
_set('axes.titleweight', 'normal') # font weight of title
|
199
|
+
# Color of the axes title, auto falls back tO text.color as default value
|
200
|
+
_set('axes.titlecolor', 'auto')
|
201
|
+
_set('axes.titley', None) # position title (axes relative units). None implies auto
|
202
|
+
_set('axes.titlepad', 6.0) # pad between axes and title in points
|
203
|
+
_set('axes.labelsize', 'medium') # font size of the x and y labels
|
204
|
+
_set('axes.labelpad', 4.0) # space between label and axis
|
205
|
+
_set('axes.labelweight', 'normal') # weight of the x and y labels
|
206
|
+
_set('axes.labelcolor', 'black')
|
207
|
+
# Draw axis gridlines and ticks:
|
208
|
+
# - below patches (True)
|
209
|
+
# - above patches but below lines ('line')
|
210
|
+
# - above all (False)
|
211
|
+
_set('axes.axisbelow', 'line')
|
212
|
+
# Use scientific notation if log10 of the axis range is smaller than the
|
213
|
+
# first or larger than the second
|
214
|
+
_set('axes.formatter.limits', (-5, 6))
|
215
|
+
_set('axes.formatter.use_locale', False)
|
216
|
+
# When True, use mathtext for scientific notation.
|
217
|
+
_set('axes.formatter.use_mathtext', False)
|
218
|
+
# Minimum exponent to format in scientific notation
|
219
|
+
_set('axes.formatter.min_exponent', 0)
|
220
|
+
# If True, the tick label formatter will default to labeling ticks relative
|
221
|
+
# to an offset when the data range is small compared to the minimum absolute
|
222
|
+
# value of the data.
|
223
|
+
_set('axes.formatter.useoffset', True)
|
224
|
+
# When useoffset is True, the offset will be used when it can remove
|
225
|
+
# at least this number of significant digits from tick labels.
|
226
|
+
_set('axes.formatter.offset_threshold', 4)
|
227
|
+
_set('axes.spines.left', True) # display axis spines
|
228
|
+
_set('axes.spines.bottom', True)
|
229
|
+
_set('axes.spines.top', True)
|
230
|
+
_set('axes.spines.right', True)
|
231
|
+
# use Unicode for the minus symbol rather than hyphen. See
|
232
|
+
# https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
|
233
|
+
_set('axes.unicode_minus', True)
|
234
|
+
_set('axes.prop_cycle', cycler('color', DEFAULT_COLOR_CYCLE))
|
235
|
+
_set('axes.xmargin', .05) # x margin. See `axes.Axes.margins`
|
236
|
+
_set('axes.ymargin', .05) # y margin. See `axes.Axes.margins`
|
237
|
+
_set('axes.zmargin', .05) # z margin. See `axes.Axes.margins`
|
238
|
+
# If "data", use axes.xmargin and axes.ymargin as is.
|
239
|
+
# If "round_numbers", after application of margins, axis limits are further expanded
|
240
|
+
# to the nearest "round" number.
|
241
|
+
_set('axes.autolimit_mode', 'data')
|
242
|
+
_set('polaraxes.grid', True) # display grid on polar axes
|
243
|
+
_set('axes3d.grid', True) # display grid on 3D axes
|
244
|
+
# Automatically add margin when manually setting 3D axis limits
|
245
|
+
_set('axes3d.automargin', False)
|
246
|
+
_set('axes3d.xaxis.panecolor', (0.95, 0.95, 0.95, 0.5)) # background pane on 3D axes
|
247
|
+
_set('axes3d.yaxis.panecolor', (0.90, 0.90, 0.90, 0.5)) # background pane on 3D axes
|
248
|
+
_set('axes3d.zaxis.panecolor', (0.925, 0.925, 0.925, 0.5)) # background pane on 3D axes
|
249
|
+
_set('axes3d.mouserotationstyle', 'arcball') # {azel, trackball, sphere, arcball}
|
250
|
+
_set('axes3d.trackballsize', 0.667) # trackball diameter, in units of the Axes bbox
|
251
|
+
# trackball border width, in units of the Axes bbox (only for 'sphere' and 'arcball' style)
|
252
|
+
_set('axes3d.trackballborder', 0.2)
|
253
|
+
|
254
|
+
# Axis
|
255
|
+
_set('xaxis.labellocation', 'center') # {left, right, center}
|
256
|
+
_set('yaxis.labellocation', 'center') # {bottom, top, center}
|
257
|
+
|
258
|
+
# Dates
|
259
|
+
# These control the default format strings used in AutoDateFormatter.
|
260
|
+
_set('date.autoformatter.year', '%Y')
|
261
|
+
_set('date.autoformatter.month', '%Y-%m')
|
262
|
+
_set('date.autoformatter.day', '%Y-%m-%d')
|
263
|
+
_set('date.autoformatter.hour', '%m-%d %H')
|
264
|
+
_set('date.autoformatter.minute', '%d %H:%M')
|
265
|
+
_set('date.autoformatter.second', '%H:%M:%S')
|
266
|
+
_set('date.autoformatter.microsecond', '%M:%S.%f')
|
267
|
+
# The reference date for Matplotlib's internal date representation
|
268
|
+
# See https://matplotlib.org/stable/gallery/ticks/date_precision_and_epochs.html
|
269
|
+
_set('date.epoch', '1970-01-01T00:00:00')
|
270
|
+
_set('date.converter', 'auto') # {auto, concise}
|
271
|
+
# For auto converter whether to use interval_multiples:
|
272
|
+
_set('date.interval_multiples', True)
|
273
|
+
|
274
|
+
# Ticks
|
275
|
+
# See https://matplotlib.org/stable/api/axis_api.html#matplotlib.axis.Tick
|
276
|
+
_set('xtick.top', False) # draw ticks on the top side
|
277
|
+
_set('xtick.bottom', True) # draw ticks on the bottom side
|
278
|
+
_set('xtick.labeltop', False) # draw label on the top
|
279
|
+
_set('xtick.labelbottom', True) # draw label on the bottom
|
280
|
+
_set('xtick.major.size', 3.5) # major tick size in points
|
281
|
+
_set('xtick.minor.size', 2) # minor tick size in points
|
282
|
+
_set('xtick.major.width', 0.8) # major tick width in points
|
283
|
+
_set('xtick.minor.width', 0.6) # minor tick width in points
|
284
|
+
_set('xtick.major.pad', 3.5) # distance to major tick label in points
|
285
|
+
_set('xtick.minor.pad', 3.4) # distance to the minor tick label in points
|
286
|
+
_set('xtick.color', 'black') # color of the ticks
|
287
|
+
# Color of the tick labels or inherit from xtick.color
|
288
|
+
_set('xtick.labelcolor', 'inherit')
|
289
|
+
_set('xtick.labelsize', 'medium') # font size of the tick labels
|
290
|
+
_set('xtick.direction', 'out') # direction: {in, out, inout}
|
291
|
+
_set('xtick.minor.visible', False) # visibility of minor ticks on x-axis
|
292
|
+
_set('xtick.major.top', True) # draw x axis top major ticks
|
293
|
+
_set('xtick.major.bottom', True) # draw x axis bottom major ticks
|
294
|
+
_set('xtick.minor.top', True) # draw x axis top minor ticks
|
295
|
+
_set('xtick.minor.bottom', True) # draw x axis bottom minor ticks
|
296
|
+
_set('xtick.minor.ndivs', 'auto') # number of minor ticks between the major ticks on x-axis
|
297
|
+
_set('xtick.alignment', 'center') # alignment of xticks
|
298
|
+
_set('ytick.left', True) # draw ticks on the left side
|
299
|
+
_set('ytick.right', False) # draw ticks on the right side
|
300
|
+
_set('ytick.labelleft', True) # draw tick labels on the left side
|
301
|
+
_set('ytick.labelright', False) # draw tick labels on the right side
|
302
|
+
_set('ytick.major.size', 3.5) # major tick size in points
|
303
|
+
_set('ytick.minor.size', 2) # minor tick size in points
|
304
|
+
_set('ytick.major.width', 0.8) # major tick width in points
|
305
|
+
_set('ytick.minor.width', 0.6) # minor tick width in points
|
306
|
+
_set('ytick.major.pad', 3.5) # distance to major tick label in points
|
307
|
+
_set('ytick.minor.pad', 3.4) # distance to the minor tick label in points
|
308
|
+
_set('ytick.color', 'black') # color of the ticks
|
309
|
+
_set('ytick.labelcolor', 'inherit') # color of the tick labels or inherit from ytick.color
|
310
|
+
_set('ytick.labelsize', 'medium') # font size of the tick labels
|
311
|
+
_set('ytick.direction', 'out') # direction: {in, out, inout}
|
312
|
+
_set('ytick.minor.visible', False) # visibility of minor ticks on y-axis
|
313
|
+
_set('ytick.major.left', True) # draw y axis left major ticks
|
314
|
+
_set('ytick.major.right', True) # draw y axis right major ticks
|
315
|
+
_set('ytick.minor.left', True) # draw y axis left minor ticks
|
316
|
+
_set('ytick.minor.right', True) # draw y axis right minor ticks
|
317
|
+
_set('ytick.minor.ndivs', 'auto') # number of minor ticks between the major ticks on y-axis
|
318
|
+
_set('ytick.alignment', 'center_baseline') # alignment of yticks
|
319
|
+
|
320
|
+
# Grids
|
321
|
+
_set('grid.color', '#c0c0c0') # grid color
|
322
|
+
_set('grid.linestyle', '--') # line style
|
323
|
+
_set('grid.linewidth', 0.8) # in points
|
324
|
+
_set('grid.alpha', 0.8) # transparency, between 0.0 and 1.0
|
325
|
+
|
326
|
+
|
327
|
+
# Legends
|
328
|
+
_set('legend.loc', 'best')
|
329
|
+
_set('legend.frameon', True) # if True, draw the legend on a background patch
|
330
|
+
_set('legend.framealpha', 0.75) # legend patch transparency
|
331
|
+
_set('legend.facecolor', 'inherit') # inherit from axes.facecolor; or color spec
|
332
|
+
_set('legend.edgecolor', '#a0a0a0') # background patch boundary color
|
333
|
+
# If True, use a rounded box for the legend background, else a rectangle
|
334
|
+
_set('legend.fancybox', True)
|
335
|
+
_set('legend.shadow', False) # if True, give background a shadow effect
|
336
|
+
_set('legend.numpoints', 1) # the number of marker points in the legend line
|
337
|
+
_set('legend.scatterpoints', 1) # number of scatter points
|
338
|
+
_set('legend.markerscale', 1.0) # the relative size of legend markers vs. original
|
339
|
+
_set('legend.fontsize', 'small')
|
340
|
+
_set('legend.labelcolor', None)
|
341
|
+
_set('legend.title_fontsize', None) # None sets to the same as the default axes.
|
342
|
+
# Dimensions as fraction of font size:
|
343
|
+
_set('legend.borderpad', 0.4) # border whitespace
|
344
|
+
_set('legend.labelspacing', 0.5) # the vertical space between the legend entries
|
345
|
+
_set('legend.handlelength', 2.0) # the length of the legend lines
|
346
|
+
_set('legend.handleheight', 0.7) # the height of the legend handle
|
347
|
+
_set('legend.handletextpad', 0.8) # the space between the legend line and legend text
|
348
|
+
_set('legend.borderaxespad', 0.5) # the border between the axes and legend edge
|
349
|
+
_set('legend.columnspacing', 2.0) # column separation
|
350
|
+
|
351
|
+
# Figures
|
352
|
+
## See https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure
|
353
|
+
_set('figure.titlesize', 'large') # size of the figure title
|
354
|
+
_set('figure.titleweight', 'normal') # weight of the figure title
|
355
|
+
_set('figure.labelsize', 'large') # size of the figure label
|
356
|
+
_set('figure.labelweight', 'normal') # weight of the figure label
|
357
|
+
_set('figure.figsize', DEFAULT_FIGURE_SIZE) # figure size in inches
|
358
|
+
_set('figure.dpi', 100) # figure dots per inch
|
359
|
+
_set('figure.facecolor', 'white') # figure face color
|
360
|
+
_set('figure.edgecolor', 'white') # figure edge color
|
361
|
+
_set('figure.frameon', True) # enable figure frame
|
362
|
+
_set('figure.max_open_warning', 20)
|
363
|
+
_set('figure.raise_window', True) # Raise the GUI window to front when show() is called
|
364
|
+
# The figure subplot parameters.
|
365
|
+
# All dimensions are a fraction of the figure width and height.
|
366
|
+
_set('figure.subplot.left', 0.125) # the left side of the subplots of the figure
|
367
|
+
_set('figure.subplot.right', 0.97) # the right side of the subplots of the figure
|
368
|
+
_set('figure.subplot.bottom', 0.11) # the bottom of the subplots of the figure
|
369
|
+
_set('figure.subplot.top', 0.96) # the top of the subplots of the figure
|
370
|
+
# Amount of width reserved for space between subplots, expressed as a fraction
|
371
|
+
# of the average axis width.
|
372
|
+
_set('figure.subplot.wspace', 0.2)
|
373
|
+
# Amount of height reserved for space between subplots, expressed as a fraction
|
374
|
+
# of the average axis height
|
375
|
+
_set('figure.subplot.hspace', 0.2)
|
376
|
+
# When True, automatically adjust subplot parameters to make the plot fit the figure
|
377
|
+
# using `tight_layout`
|
378
|
+
_set('figure.autolayout', False)
|
379
|
+
# When True, automatically make plot elements fit on the figure.
|
380
|
+
# (Not compatible with `autolayout`, above).
|
381
|
+
_set('figure.constrained_layout.use', False)
|
382
|
+
# Padding (in inches) around axes; defaults to 3/72 inches, i.e. 3 points.
|
383
|
+
_set('figure.constrained_layout.h_pad', 0.04167)
|
384
|
+
_set('figure.constrained_layout.w_pad', 0.04167)
|
385
|
+
# Spacing between subplots, relative to the subplot sizes. Much smaller than for
|
386
|
+
# tight_layout (figure.subplot.hspace, figure.subplot.wspace) as constrained_layout
|
387
|
+
# already takes surrounding texts (titles, labels, # ticklabels) into account.
|
388
|
+
_set('figure.constrained_layout.hspace', 0.02)
|
389
|
+
_set('figure.constrained_layout.wspace', 0.02)
|
390
|
+
|
391
|
+
# Images
|
392
|
+
_set('image.aspect', 'equal') # {equal, auto} or a number
|
393
|
+
_set('image.interpolation', 'auto') # see help(imshow) for options
|
394
|
+
_set('image.interpolation_stage', 'auto') # see help(imshow) for options
|
395
|
+
_set('image.cmap', 'viridis') # A colormap name (plasma, magma, etc.)
|
396
|
+
_set('image.lut', 256) # the size of the colormap lookup table
|
397
|
+
_set('image.origin', 'upper') # {lower, upper}
|
398
|
+
_set('image.resample', True)
|
399
|
+
# When True, all the images on a set of axes are combined into a single composite
|
400
|
+
# image before saving a figure as a vector graphics file, such as a PDF.
|
401
|
+
_set('image.composite_image', True)
|
402
|
+
|
403
|
+
# Various plots.
|
404
|
+
_set('contour.negative_linestyle', 'dashed') # string or on-off ink sequence
|
405
|
+
_set('contour.corner_mask', True) # {True, False}
|
406
|
+
_set('contour.linewidth', None)
|
407
|
+
_set('contour.algorithm', 'mpl2014') # {mpl2005, mpl2014, serial, threaded}
|
408
|
+
_set('errorbar.capsize', 0) # length of end cap on error bars in pixels
|
409
|
+
_set('hist.bins', 10) # The default number of histogram bins or 'auto'.
|
410
|
+
_set('scatter.marker', 'o') # The default marker type for scatter plots.
|
411
|
+
_set('scatter.edgecolors', 'face') # The default edge colors for scatter plots.
|
412
|
+
|
413
|
+
# Paths
|
414
|
+
# When True, simplify paths by removing "invisible" points to reduce file size
|
415
|
+
# and increase rendering speed
|
416
|
+
_set('path.simplify', True)
|
417
|
+
# The threshold of similarity below which vertices will be removed in
|
418
|
+
# the simplification process.
|
419
|
+
_set('path.simplify_threshold', 0.111111111111)
|
420
|
+
# When True, rectilinear axis-aligned paths will be snapped to the nearest pixel
|
421
|
+
# when certain criteria are met. When False, paths will never be snapped.
|
422
|
+
_set('path.snap', True)
|
423
|
+
# May be None, or a tuple of the form: path.sketch: (scale, length, randomness)
|
424
|
+
# - scale is the amplitude of the wiggle perpendicular to the line (in pixels).
|
425
|
+
# - length is the length of the wiggle along the line (in pixels).
|
426
|
+
# - randomness is the factor by which the length is randomly scaled.
|
427
|
+
_set('path.sketch', None)
|
428
|
+
|
429
|
+
# Saving figures...
|
430
|
+
# The default savefig parameters can be different from the display parameters
|
431
|
+
_set('savefig.dpi', 300) # figure dots per inch or 'figure'
|
432
|
+
_set('savefig.facecolor', 'auto') # figure face color when saving
|
433
|
+
_set('savefig.edgecolor', 'auto') # figure edge color when saving
|
434
|
+
_set('savefig.format', 'png') # {png, ps, pdf, svg}
|
435
|
+
_set('savefig.bbox', 'standard') # {tight, standard}
|
436
|
+
_set('savefig.pad_inches', 0.1) # padding to be used, when bbox is set to 'tight'
|
437
|
+
# Default directory in savefig dialog, gets updated after interactive saves,
|
438
|
+
# unless set to the empty string (i.e. the current directory); use '.' to start
|
439
|
+
# at the current directory but update after interactive saves
|
440
|
+
_set('savefig.directory', '')
|
441
|
+
# Whether figures are saved with a transparent background by default
|
442
|
+
_set('savefig.transparent', False)
|
443
|
+
# Orientation of saved figure, for PostScript output only
|
444
|
+
_set('savefig.orientation', 'portrait')
|
445
|
+
_set('macosx.window_mode', 'system')
|
446
|
+
_set('tk.window_focus', False) # Maintain shell focus for TkAgg
|
447
|
+
# Integer from 0 to 9, 0 disables compression (good for debugging)
|
448
|
+
_set('pdf.compression', 6)
|
449
|
+
_set('pdf.fonttype', 3) # Output Type 3 (Type3) or Type 42 (TrueType)
|
450
|
+
_set('pdf.use14corefonts', False)
|
451
|
+
_set('pdf.inheritcolor', False)
|
452
|
+
_set('svg.image_inline', True) # Write raster image data directly into the SVG file
|
453
|
+
# How to handle SVG fonts:
|
454
|
+
# - path: embed characters as paths -- supported by most SVG renderers
|
455
|
+
# - None: assume fonts are installed on the machine where the SVG will be viewed.
|
456
|
+
_set('svg.fonttype', 'path')
|
457
|
+
_set('svg.hashsalt', None) # If not None, use this string as hash salt instead of uuid4
|
458
|
+
# If not None, use this string as the value for the `id` attribute in the top <svg> tag
|
459
|
+
_set('svg.id', None)
|
460
|
+
# See https://matplotlib.org/stable/tutorials/text/pgf.html for more information.
|
461
|
+
_set('pgf.rcfonts', True)
|
462
|
+
_set('pgf.texsystem', 'xelatex')
|
463
|
+
_set('docstring.hardcopy', False) # set this when you want to generate hardcopy docstring
|
464
|
+
|
465
|
+
# Animations
|
466
|
+
# How to display the animation as HTML in the IPython notebook:
|
467
|
+
# - 'html5' uses HTML5 video tag
|
468
|
+
# - 'jshtml' creates a JavaScript animation
|
469
|
+
_set('animation.html', 'none')
|
470
|
+
_set('animation.writer', 'ffmpeg') # MovieWriter 'backend' to use
|
471
|
+
_set('animation.codec', 'h264') # Codec to use for writing movie
|
472
|
+
# Controls size/quality trade-off for movie.
|
473
|
+
# -1 implies let utility auto-determine
|
474
|
+
_set('animation.bitrate', -1)
|
475
|
+
_set('animation.frame_format', 'png') # Controls frame format used by temp files
|
476
|
+
# Path to ffmpeg binary. Unqualified paths are resolved by subprocess.Popen.
|
477
|
+
_set('animation.ffmpeg_path', 'ffmpeg')
|
478
|
+
# Path to ImageMagick's convert binary. Unqualified paths are resolved by
|
479
|
+
# subprocess.Popen, except that on Windows, we look up an install of
|
480
|
+
# ImageMagick in the registry (as convert is also the name of a system tool).
|
481
|
+
_set('animation.convert_path', 'convert')
|
482
|
+
# Limit, in MB, of size of base64 encoded animation in HTML (i.e. IPython notebook)
|
483
|
+
_set('animation.embed_limit', 20.0)
|
484
|
+
|
485
|
+
|
486
|
+
configure()
|
aptapy/py.typed
ADDED
File without changes
|
aptapy/typing_.py
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright (C) 2025 Luca Baldini (luca.baldini@pi.infn.it)
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
"""Type annotations.
|
17
|
+
"""
|
18
|
+
|
19
|
+
from typing import Union
|
20
|
+
|
21
|
+
import numpy as np
|
22
|
+
|
23
|
+
ArrayLike = Union[float, np.ndarray]
|