myplotlib 1.3.0__tar.gz → 1.5.0__tar.gz
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.
- {myplotlib-1.3.0 → myplotlib-1.5.0}/LICENSE +1 -1
- {myplotlib-1.3.0 → myplotlib-1.5.0}/PKG-INFO +27 -9
- {myplotlib-1.3.0 → myplotlib-1.5.0}/README.md +25 -7
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/__init__.py +28 -29
- myplotlib-1.5.0/myplotlib/assets/latex.mplstyle +2 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/plots.py +134 -6
- {myplotlib-1.3.0 → myplotlib-1.5.0}/previews/README.md +14 -10
- myplotlib-1.5.0/previews/export_previews.py +30 -0
- myplotlib-1.5.0/previews/fancy_dark.jpg +0 -0
- myplotlib-1.5.0/previews/fancy_light.jpg +0 -0
- myplotlib-1.5.0/previews/hershey_dark.jpg +0 -0
- myplotlib-1.5.0/previews/hershey_light.jpg +0 -0
- myplotlib-1.5.0/previews/latex.jpg +0 -0
- myplotlib-1.5.0/previews/mono_dark.jpg +0 -0
- myplotlib-1.5.0/previews/mono_light.jpg +0 -0
- myplotlib-1.5.0/previews/plain.jpg +0 -0
- myplotlib-1.3.0/previews/None.jpg +0 -0
- myplotlib-1.3.0/previews/export_previews.py +0 -29
- myplotlib-1.3.0/previews/fancy_dark.jpg +0 -0
- myplotlib-1.3.0/previews/fancy_light.jpg +0 -0
- myplotlib-1.3.0/previews/hershey_dark.jpg +0 -0
- myplotlib-1.3.0/previews/hershey_light.jpg +0 -0
- myplotlib-1.3.0/previews/mono_dark.jpg +0 -0
- myplotlib-1.3.0/previews/mono_light.jpg +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/.github/workflows/pypi-publish.yml +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/.gitignore +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/MANIFEST.in +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/colormaps/bipolar.csv +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/colormaps/colt.csv +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/colormaps/fire.csv +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/colormaps/idl.csv +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/colormaps/sunrise.csv +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/colormaps/thermal.csv +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/colormaps/vanilla.csv +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fancy.dark.mplstyle +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fancy.light.mplstyle +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/AppleChancery.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-Bold.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-BoldItalic.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-ExtraBold.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-ExtraBoldItalic.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-Italic.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-Medium.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-MediumItalic.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-Regular.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-SemiBold.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/EBGaramond-SemiBoldItalic.ttf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/HersheyTex-Book.otf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/fonts/HersheyTex-Light.otf +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/hershey.dark.mplstyle +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/hershey.light.mplstyle +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/mono.dark.mplstyle +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/assets/mono.light.mplstyle +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/tests.py +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/tools/__init__.py +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/myplotlib/tools/lic.py +0 -0
- {myplotlib-1.3.0 → myplotlib-1.5.0}/pyproject.toml +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: myplotlib
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: `matplotlib` binder with custom styles and routines for fast plotting
|
|
5
5
|
Project-URL: Repository, https://github.com/haykh/myplotlib
|
|
6
6
|
Author-email: Hayk <haykh.astro@gmail.com>
|
|
7
7
|
Maintainer-email: Hayk <haykh.astro@gmail.com>
|
|
8
8
|
License: BSD 3-Clause License
|
|
9
9
|
|
|
10
|
-
Copyright (c)
|
|
10
|
+
Copyright (c) 2024, Hayk Hakobyan
|
|
11
11
|
|
|
12
12
|
Redistribution and use in source and binary forms, with or without
|
|
13
13
|
modification, are permitted provided that the following conditions are met:
|
|
@@ -64,19 +64,37 @@ pip install myplotlib
|
|
|
64
64
|
|
|
65
65
|
### usage
|
|
66
66
|
|
|
67
|
+
#### loading style, fonts & colormaps
|
|
68
|
+
|
|
67
69
|
```python
|
|
68
|
-
# initialize style:
|
|
69
70
|
import myplotlib
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
#
|
|
71
|
+
import matplotlib.pyplot as plt
|
|
72
|
+
|
|
73
|
+
plt.style.use(STYLE)
|
|
74
|
+
# STYLE can be:
|
|
75
|
+
# - fancy.dark, fancy.light
|
|
76
|
+
# - hershey.dark, hershey.light
|
|
77
|
+
# - mono.dark, mono.light
|
|
78
|
+
# - latex
|
|
79
|
+
|
|
80
|
+
# you may also combine the styles:
|
|
81
|
+
plt.style.use([STYLE1, STYLE2])
|
|
82
|
+
|
|
83
|
+
# and you can temporarily load the style:
|
|
84
|
+
with plt.style.context(STYLE):
|
|
85
|
+
plt.plot(...)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### auxiliary plotting functions
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
```python
|
|
76
91
|
import myplotlib.plots as myplt
|
|
77
92
|
# type for docstring:
|
|
78
93
|
myplt?
|
|
79
94
|
|
|
95
|
+
# for specific function:
|
|
96
|
+
myplt.plot2d?
|
|
97
|
+
|
|
80
98
|
# preview custom styles with built-in functions
|
|
81
99
|
import myplotlib.tests as mypltest
|
|
82
100
|
# type for docstring:
|
|
@@ -88,7 +106,7 @@ for more usage examples checkout the `tests/` submodule.
|
|
|
88
106
|
### requirements
|
|
89
107
|
|
|
90
108
|
* `python >= 3.8`
|
|
91
|
-
* `matplotlib >= 3.
|
|
109
|
+
* `matplotlib >= 3.5.0`, `numpy`
|
|
92
110
|
* `latex` (used for `style="fancy"` only)
|
|
93
111
|
* `numba>=0.57.0`
|
|
94
112
|
|
|
@@ -10,19 +10,37 @@ pip install myplotlib
|
|
|
10
10
|
|
|
11
11
|
### usage
|
|
12
12
|
|
|
13
|
+
#### loading style, fonts & colormaps
|
|
14
|
+
|
|
13
15
|
```python
|
|
14
|
-
# initialize style:
|
|
15
16
|
import myplotlib
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
#
|
|
17
|
+
import matplotlib.pyplot as plt
|
|
18
|
+
|
|
19
|
+
plt.style.use(STYLE)
|
|
20
|
+
# STYLE can be:
|
|
21
|
+
# - fancy.dark, fancy.light
|
|
22
|
+
# - hershey.dark, hershey.light
|
|
23
|
+
# - mono.dark, mono.light
|
|
24
|
+
# - latex
|
|
25
|
+
|
|
26
|
+
# you may also combine the styles:
|
|
27
|
+
plt.style.use([STYLE1, STYLE2])
|
|
28
|
+
|
|
29
|
+
# and you can temporarily load the style:
|
|
30
|
+
with plt.style.context(STYLE):
|
|
31
|
+
plt.plot(...)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### auxiliary plotting functions
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
```python
|
|
22
37
|
import myplotlib.plots as myplt
|
|
23
38
|
# type for docstring:
|
|
24
39
|
myplt?
|
|
25
40
|
|
|
41
|
+
# for specific function:
|
|
42
|
+
myplt.plot2d?
|
|
43
|
+
|
|
26
44
|
# preview custom styles with built-in functions
|
|
27
45
|
import myplotlib.tests as mypltest
|
|
28
46
|
# type for docstring:
|
|
@@ -34,7 +52,7 @@ for more usage examples checkout the `tests/` submodule.
|
|
|
34
52
|
### requirements
|
|
35
53
|
|
|
36
54
|
* `python >= 3.8`
|
|
37
|
-
* `matplotlib >= 3.
|
|
55
|
+
* `matplotlib >= 3.5.0`, `numpy`
|
|
38
56
|
* `latex` (used for `style="fancy"` only)
|
|
39
57
|
* `numba>=0.57.0`
|
|
40
58
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
__version__ = "1.
|
|
1
|
+
__version__ = "1.5.0"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
from matplotlib import font_manager
|
|
7
|
+
|
|
8
|
+
import myplotlib
|
|
4
9
|
|
|
5
10
|
|
|
6
11
|
def __RGBToPyCmap(rgbdata):
|
|
@@ -22,6 +27,9 @@ def __RGBToPyCmap(rgbdata):
|
|
|
22
27
|
return mpl_data
|
|
23
28
|
|
|
24
29
|
|
|
30
|
+
CUSTOM_CMAPS = []
|
|
31
|
+
|
|
32
|
+
|
|
25
33
|
def __InstallCmapFromCSV(csv):
|
|
26
34
|
global CUSTOM_CMAPS
|
|
27
35
|
import os
|
|
@@ -46,32 +54,23 @@ def __InstallCmapFromCSV(csv):
|
|
|
46
54
|
)
|
|
47
55
|
|
|
48
56
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`myplotlib.load`
|
|
57
|
+
myplotlib_path = myplotlib.__path__[0]
|
|
58
|
+
styles_path = os.path.join(myplotlib_path, "assets")
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
stylesheets = {}
|
|
61
|
+
for folder, _, _ in os.walk(styles_path):
|
|
62
|
+
new_stylesheets = plt.style.core.read_style_directory(folder)
|
|
63
|
+
stylesheets.update(new_stylesheets)
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
cmapname = os.path.join(CMAP_DIR, cmap)
|
|
68
|
-
__InstallCmapFromCSV(cmapname)
|
|
69
|
-
FONT_DIR = os.path.join(os.path.dirname(__file__), "assets/fonts")
|
|
70
|
-
font_files = font_manager.findSystemFonts(fontpaths=[FONT_DIR])
|
|
71
|
-
for font_file in font_files:
|
|
72
|
-
font_manager.fontManager.addfont(font_file)
|
|
73
|
-
if style is not None:
|
|
74
|
-
MPLSTYLE_FILE = os.path.join(
|
|
75
|
-
os.path.dirname(__file__), f"assets/{style}.{flavor}.mplstyle"
|
|
76
|
-
)
|
|
77
|
-
plt.style.use(MPLSTYLE_FILE)
|
|
65
|
+
plt.style.core.update_nested_dict(plt.style.library, stylesheets)
|
|
66
|
+
plt.style.core.available[:] = sorted(plt.style.library.keys())
|
|
67
|
+
|
|
68
|
+
CMAP_DIR = os.path.join(myplotlib_path, "assets/colormaps")
|
|
69
|
+
CMAPS = os.listdir(CMAP_DIR)
|
|
70
|
+
for cmap in CMAPS:
|
|
71
|
+
cmapname = os.path.join(CMAP_DIR, cmap)
|
|
72
|
+
__InstallCmapFromCSV(cmapname)
|
|
73
|
+
FONT_DIR = os.path.join(myplotlib_path, "assets/fonts")
|
|
74
|
+
font_files = font_manager.findSystemFonts(fontpaths=[FONT_DIR])
|
|
75
|
+
for font_file in font_files:
|
|
76
|
+
font_manager.fontManager.addfont(font_file)
|
|
@@ -126,7 +126,7 @@ def dataPlot(
|
|
|
126
126
|
xlog [False], ylog [False] .. : use log in x or y direction
|
|
127
127
|
xlim [None], ylim [None] .... : tuples of x and y limits (None = determine from data)
|
|
128
128
|
padx [0], pady [0] .......... : add whitespace to axes in each direction (0 = no additional space)
|
|
129
|
-
**kwargs .................... : standard matplotlib kwargs passed to `ax
|
|
129
|
+
**kwargs .................... : standard matplotlib kwargs passed to `ax.<function>`
|
|
130
130
|
"""
|
|
131
131
|
if padx != 0:
|
|
132
132
|
ax.spines["top"].set_visible(False)
|
|
@@ -169,7 +169,7 @@ def plot(
|
|
|
169
169
|
xlog [False], ylog [False] .. : use log in x or y direction
|
|
170
170
|
xlim [None], ylim [None] .... : tuples of x and y limits (None = determine from data)
|
|
171
171
|
padx [0], pady [0] .......... : add whitespace to axes in each direction (0 = no additional space)
|
|
172
|
-
**kwargs .................... : standard matplotlib kwargs passed to `ax.
|
|
172
|
+
**kwargs .................... : standard matplotlib kwargs passed to `ax.plot`
|
|
173
173
|
"""
|
|
174
174
|
dataPlot(ax.plot, ax, x, y, xlog, ylog, xlim, ylim, padx, pady, **kwargs)
|
|
175
175
|
|
|
@@ -189,6 +189,7 @@ def plot2d(
|
|
|
189
189
|
pady=0.0,
|
|
190
190
|
cbar="5%",
|
|
191
191
|
cbar_pad=0.05,
|
|
192
|
+
cbar_pos="right",
|
|
192
193
|
**kwargs,
|
|
193
194
|
):
|
|
194
195
|
"""
|
|
@@ -206,7 +207,8 @@ def plot2d(
|
|
|
206
207
|
padx [0], pady [0] .......... : add whitespace to axes in each direction (0 = no additional space)
|
|
207
208
|
cbar ['5%'] ................. : size of the colorbar in percent of x-axis (None = no colorbar)
|
|
208
209
|
cbar_pad [0.05] ............. : padding of the colorbar
|
|
209
|
-
|
|
210
|
+
cbar_pos ['right'] .......... : position of the colorbar ('left', 'right', 'top', 'bottom')
|
|
211
|
+
**kwargs .................... : standard matplotlib kwargs passed to `ax.imshow`
|
|
210
212
|
|
|
211
213
|
returns
|
|
212
214
|
----------
|
|
@@ -217,6 +219,9 @@ def plot2d(
|
|
|
217
219
|
import matplotlib.pyplot as plt
|
|
218
220
|
import matplotlib as mpl
|
|
219
221
|
|
|
222
|
+
assert centering in ["edge", "center"], "invalid `centering`"
|
|
223
|
+
assert cbar_pos in ["left", "right", "top", "bottom"], "invalid `cbar_pos`"
|
|
224
|
+
|
|
220
225
|
x, y, zz = __checkDimensions2d(x, y, zz)
|
|
221
226
|
ax.grid(False)
|
|
222
227
|
extent = __findExtent(x, y, centering)
|
|
@@ -241,8 +246,23 @@ def plot2d(
|
|
|
241
246
|
__setAxLims(ax, np.linspace(extent[2], extent[3]), False, pady, ylim, "left")
|
|
242
247
|
if cbar is not None:
|
|
243
248
|
divider = make_axes_locatable(ax)
|
|
244
|
-
cax = divider.append_axes(
|
|
245
|
-
colorbar = plt.colorbar(
|
|
249
|
+
cax = divider.append_axes(cbar_pos, size=cbar, pad=cbar_pad)
|
|
250
|
+
colorbar = plt.colorbar(
|
|
251
|
+
ax.get_images()[0],
|
|
252
|
+
cax=cax,
|
|
253
|
+
orientation="vertical" if cbar_pos in ["left", "right"] else "horizontal",
|
|
254
|
+
)
|
|
255
|
+
if cbar_pos == "left":
|
|
256
|
+
cax.yaxis.set_ticks_position("left")
|
|
257
|
+
cax.yaxis.set_label_position("left")
|
|
258
|
+
ax.yaxis.set_ticks_position("right")
|
|
259
|
+
ax.yaxis.set_label_position("right")
|
|
260
|
+
if cbar_pos == "top":
|
|
261
|
+
cax.xaxis.set_ticks_position("top")
|
|
262
|
+
cax.xaxis.set_label_position("top")
|
|
263
|
+
if cbar_pos == "bottom":
|
|
264
|
+
ax.xaxis.set_ticks_position("top")
|
|
265
|
+
ax.xaxis.set_label_position("top")
|
|
246
266
|
return colorbar
|
|
247
267
|
else:
|
|
248
268
|
return None
|
|
@@ -302,7 +322,7 @@ def plotVectorField(
|
|
|
302
322
|
padx [0], pady [0] .......... : add whitespace to axes in each direction (0 = no additional space)
|
|
303
323
|
cbar ['5%'] ................. : size of the colorbar in percent of x-axis (None = no colorbar)
|
|
304
324
|
cbar_pad [0.05] ............. : padding of the colorbar
|
|
305
|
-
**kwargs .................... : standard matplotlib kwargs passed to `ax.
|
|
325
|
+
**kwargs .................... : standard matplotlib kwargs passed to `ax.imshow`
|
|
306
326
|
"""
|
|
307
327
|
import myplotlib.tools.lic as lic
|
|
308
328
|
import matplotlib
|
|
@@ -370,3 +390,111 @@ def plotVectorField(
|
|
|
370
390
|
alpha=lic_opacity,
|
|
371
391
|
)
|
|
372
392
|
return colorbar
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def plot2dGrid(
|
|
396
|
+
x,
|
|
397
|
+
y,
|
|
398
|
+
fields,
|
|
399
|
+
panels,
|
|
400
|
+
label_pos="title",
|
|
401
|
+
label_args={},
|
|
402
|
+
width=10,
|
|
403
|
+
dpi=150,
|
|
404
|
+
wspace=0.05,
|
|
405
|
+
hspace=0.05,
|
|
406
|
+
**kwargs,
|
|
407
|
+
):
|
|
408
|
+
"""
|
|
409
|
+
add a grid of 2d plots with shared axes
|
|
410
|
+
|
|
411
|
+
args
|
|
412
|
+
----------
|
|
413
|
+
x, y ........................ : 1d or 2d arrays of coordinates
|
|
414
|
+
fields ...................... : dictionary of all the fields
|
|
415
|
+
panels ...................... : array of array of dictionaries indicating the panels to plot (see note below)
|
|
416
|
+
label_pos ['title'] ......... : position of the label ('title', 'cbar', 'text', None)
|
|
417
|
+
label_args [{}] ............. : arguments for the label (color, fontsize, etc; passed to `ax.set_title`, )
|
|
418
|
+
|
|
419
|
+
arguments for the figure
|
|
420
|
+
----------
|
|
421
|
+
width [10] .................. : width of the figure in inches
|
|
422
|
+
dpi [150] ................... : resolution of the figure [dots per inch]
|
|
423
|
+
wspace [0.05] ............... : width space between the panels (as fraction of the panel width)
|
|
424
|
+
hspace [0.05] ............... : height space between the panels (as fraction of the panel height)
|
|
425
|
+
|
|
426
|
+
the rest of the args are the same as for the `plot2d`
|
|
427
|
+
----------
|
|
428
|
+
force_aspect [True] ......... : force equal aspect ratio according to axes
|
|
429
|
+
centering ['edge'] .......... : centering of x & y nodes for the data ('edge', 'center')
|
|
430
|
+
xlim [None], ylim [None] .... : tuples of x and y limits (None = determine from x & y)
|
|
431
|
+
padx [0], pady [0] .......... : add whitespace to axes in each direction (0 = no additional space)
|
|
432
|
+
cbar ['5%'] ................. : size of the colorbar in percent of x-axis (None = no colorbar)
|
|
433
|
+
cbar_pad [0.05] ............. : padding of the colorbar
|
|
434
|
+
**kwargs .................... : standard matplotlib kwargs passed to `ax.imshow`
|
|
435
|
+
|
|
436
|
+
note
|
|
437
|
+
----------
|
|
438
|
+
the `panels` is an `n x m` array, where `n` is the number of rows and `m` is the number of columns.
|
|
439
|
+
each element of the array is a dictionary with the following keys:
|
|
440
|
+
- 'label' ............... : label for the field
|
|
441
|
+
- 'field' ............... : lambda function which takes the `fields` dictionary and returns the quantity to plot
|
|
442
|
+
- 'cmap' ................ : colormap of the panel
|
|
443
|
+
- 'norm' ................ : normalization object
|
|
444
|
+
"""
|
|
445
|
+
import matplotlib.pyplot as plt
|
|
446
|
+
|
|
447
|
+
assert len(panels) > 0, "no panels to plot"
|
|
448
|
+
assert len(panels[0]) > 0, "no panels to plot"
|
|
449
|
+
assert all(
|
|
450
|
+
[len(row) == len(panels[0]) for row in panels]
|
|
451
|
+
), "all rows must have the same number of panels"
|
|
452
|
+
assert label_pos in ["title", "cbar", "text", None], "invalid label position"
|
|
453
|
+
|
|
454
|
+
ncols = len(panels[0])
|
|
455
|
+
nrows = len(panels)
|
|
456
|
+
|
|
457
|
+
xlims = kwargs.get("xlim", (x.min(), x.max()))
|
|
458
|
+
ylims = kwargs.get("ylim", (y.min(), y.max()))
|
|
459
|
+
aspect = (xlims[1] - xlims[0]) / (ylims[1] - ylims[0])
|
|
460
|
+
height = (
|
|
461
|
+
width
|
|
462
|
+
* ((nrows + hspace * (nrows - 1)) / (ncols + wspace * (ncols - 1)))
|
|
463
|
+
/ aspect
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
fig = plt.figure(figsize=(width, height), dpi=dpi)
|
|
467
|
+
|
|
468
|
+
gs = fig.add_gridspec(nrows, ncols, wspace=wspace, hspace=hspace)
|
|
469
|
+
axs = [[fig.add_subplot(gs[i, j]) for j in range(ncols)] for i in range(nrows)]
|
|
470
|
+
|
|
471
|
+
label_coords = label_args.pop("position", (0.05, 0.95))
|
|
472
|
+
|
|
473
|
+
for i in range(nrows):
|
|
474
|
+
for j in range(ncols):
|
|
475
|
+
ax = axs[i][j]
|
|
476
|
+
panel = panels[i][j]
|
|
477
|
+
|
|
478
|
+
cbar = plot2d(
|
|
479
|
+
ax,
|
|
480
|
+
x,
|
|
481
|
+
y,
|
|
482
|
+
panel["field"](fields),
|
|
483
|
+
norm=panel["norm"],
|
|
484
|
+
cmap=panel["cmap"],
|
|
485
|
+
**kwargs,
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
if j != 0:
|
|
489
|
+
ax.set(ylabel=None, yticklabels=[])
|
|
490
|
+
if i != nrows - 1:
|
|
491
|
+
ax.set(xlabel=None, xticklabels=[])
|
|
492
|
+
|
|
493
|
+
if label_pos == "title":
|
|
494
|
+
ax.set_title(panel["label"], **label_args)
|
|
495
|
+
elif label_pos == "cbar":
|
|
496
|
+
cbar.set_label(panel["label"], **label_args)
|
|
497
|
+
elif label_pos == "text":
|
|
498
|
+
ax.text(
|
|
499
|
+
*label_coords, panel["label"], transform=ax.transAxes, **label_args
|
|
500
|
+
)
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
# `fancy.light`
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
1
|
# `mono.dark`
|
|
6
2
|
|
|
7
3
|

|
|
@@ -10,10 +6,6 @@
|
|
|
10
6
|
|
|
11
7
|

|
|
12
8
|
|
|
13
|
-
# `fancy.dark`
|
|
14
|
-
|
|
15
|
-

|
|
16
|
-
|
|
17
9
|
# `hershey.light`
|
|
18
10
|
|
|
19
11
|

|
|
@@ -22,7 +14,19 @@
|
|
|
22
14
|
|
|
23
15
|

|
|
24
16
|
|
|
25
|
-
# `
|
|
17
|
+
# `fancy.light`
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
# `fancy.dark`
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
# `Latex`
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
# `Plain`
|
|
26
30
|
|
|
27
|
-

|
|
28
32
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
|
|
4
|
+
import myplotlib
|
|
5
|
+
import myplotlib.tests as mypltests
|
|
6
|
+
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
readme = ""
|
|
9
|
+
|
|
10
|
+
for st, fl in [
|
|
11
|
+
f.replace(".mplstyle", "").split(".")
|
|
12
|
+
for f in os.listdir("myplotlib/assets")
|
|
13
|
+
if f.endswith(".mplstyle") and f.count(".") == 2
|
|
14
|
+
]:
|
|
15
|
+
with plt.style.context(f"{st}.{fl}"):
|
|
16
|
+
mypltests.testAll()
|
|
17
|
+
plt.savefig(f"previews/{st}_{fl}.jpg")
|
|
18
|
+
readme += f"# `{st}.{fl}`\n\n\n\n"
|
|
19
|
+
|
|
20
|
+
with plt.style.context("latex"):
|
|
21
|
+
mypltests.testAll()
|
|
22
|
+
plt.savefig(f"previews/latex.jpg")
|
|
23
|
+
readme += f"# `Latex`\n\n\n\n"
|
|
24
|
+
|
|
25
|
+
mypltests.testAll()
|
|
26
|
+
plt.savefig(f"previews/plain.jpg")
|
|
27
|
+
readme += f"# `Plain`\n\n\n\n"
|
|
28
|
+
|
|
29
|
+
with open("previews/README.md", "w") as f:
|
|
30
|
+
f.write(readme)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import matplotlib as mpl
|
|
3
|
-
import matplotlib.pyplot as plt
|
|
4
|
-
|
|
5
|
-
import myplotlib
|
|
6
|
-
import myplotlib.tests as mypltests
|
|
7
|
-
|
|
8
|
-
if __name__ == "__main__":
|
|
9
|
-
readme = ""
|
|
10
|
-
|
|
11
|
-
for st, fl in [
|
|
12
|
-
f.replace(".mplstyle", "").split(".")
|
|
13
|
-
for f in os.listdir("myplotlib/assets")
|
|
14
|
-
if f.endswith(".mplstyle")
|
|
15
|
-
]:
|
|
16
|
-
mpl.rcParams.update(mpl.rcParamsDefault)
|
|
17
|
-
myplotlib.load(st, fl)
|
|
18
|
-
mypltests.testAll()
|
|
19
|
-
plt.savefig(f"previews/{st}_{fl}.jpg")
|
|
20
|
-
readme += f"# `{st}.{fl}`\n\n\n\n"
|
|
21
|
-
|
|
22
|
-
mpl.rcParams.update(mpl.rcParamsDefault)
|
|
23
|
-
myplotlib.load(None, None)
|
|
24
|
-
mypltests.testAll()
|
|
25
|
-
plt.savefig(f"previews/None.jpg")
|
|
26
|
-
readme += f"# `None`\n\n\n\n"
|
|
27
|
-
|
|
28
|
-
with open("previews/README.md", "w") as f:
|
|
29
|
-
f.write(readme)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|