myplotlib 1.2.0__tar.gz → 1.4.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.
Files changed (55) hide show
  1. {myplotlib-1.2.0 → myplotlib-1.4.0}/LICENSE +1 -1
  2. {myplotlib-1.2.0 → myplotlib-1.4.0}/PKG-INFO +8 -7
  3. {myplotlib-1.2.0 → myplotlib-1.4.0}/README.md +4 -3
  4. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/__init__.py +15 -8
  5. myplotlib-1.4.0/myplotlib/assets/latex.mplstyle +2 -0
  6. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/plots.py +24 -7
  7. myplotlib-1.4.0/previews/None.jpg +0 -0
  8. {myplotlib-1.2.0 → myplotlib-1.4.0}/previews/export_previews.py +1 -1
  9. myplotlib-1.4.0/previews/fancy_dark.jpg +0 -0
  10. myplotlib-1.4.0/previews/fancy_light.jpg +0 -0
  11. myplotlib-1.4.0/previews/hershey_dark.jpg +0 -0
  12. myplotlib-1.4.0/previews/hershey_light.jpg +0 -0
  13. myplotlib-1.4.0/previews/mono_dark.jpg +0 -0
  14. myplotlib-1.4.0/previews/mono_light.jpg +0 -0
  15. {myplotlib-1.2.0 → myplotlib-1.4.0}/pyproject.toml +1 -1
  16. myplotlib-1.2.0/previews/None.jpg +0 -0
  17. myplotlib-1.2.0/previews/fancy_dark.jpg +0 -0
  18. myplotlib-1.2.0/previews/fancy_light.jpg +0 -0
  19. myplotlib-1.2.0/previews/hershey_dark.jpg +0 -0
  20. myplotlib-1.2.0/previews/hershey_light.jpg +0 -0
  21. myplotlib-1.2.0/previews/mono_dark.jpg +0 -0
  22. myplotlib-1.2.0/previews/mono_light.jpg +0 -0
  23. {myplotlib-1.2.0 → myplotlib-1.4.0}/.github/workflows/pypi-publish.yml +0 -0
  24. {myplotlib-1.2.0 → myplotlib-1.4.0}/.gitignore +0 -0
  25. {myplotlib-1.2.0 → myplotlib-1.4.0}/MANIFEST.in +0 -0
  26. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/colormaps/bipolar.csv +0 -0
  27. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/colormaps/colt.csv +0 -0
  28. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/colormaps/fire.csv +0 -0
  29. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/colormaps/idl.csv +0 -0
  30. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/colormaps/sunrise.csv +0 -0
  31. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/colormaps/thermal.csv +0 -0
  32. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/colormaps/vanilla.csv +0 -0
  33. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fancy.dark.mplstyle +0 -0
  34. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fancy.light.mplstyle +0 -0
  35. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/AppleChancery.ttf +0 -0
  36. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-Bold.ttf +0 -0
  37. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-BoldItalic.ttf +0 -0
  38. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-ExtraBold.ttf +0 -0
  39. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-ExtraBoldItalic.ttf +0 -0
  40. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-Italic.ttf +0 -0
  41. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-Medium.ttf +0 -0
  42. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-MediumItalic.ttf +0 -0
  43. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-Regular.ttf +0 -0
  44. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-SemiBold.ttf +0 -0
  45. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/EBGaramond-SemiBoldItalic.ttf +0 -0
  46. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/HersheyTex-Book.otf +0 -0
  47. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/fonts/HersheyTex-Light.otf +0 -0
  48. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/hershey.dark.mplstyle +0 -0
  49. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/hershey.light.mplstyle +0 -0
  50. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/mono.dark.mplstyle +0 -0
  51. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/assets/mono.light.mplstyle +0 -0
  52. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/tests.py +0 -0
  53. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/tools/__init__.py +0 -0
  54. {myplotlib-1.2.0 → myplotlib-1.4.0}/myplotlib/tools/lic.py +0 -0
  55. {myplotlib-1.2.0 → myplotlib-1.4.0}/previews/README.md +8 -8
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2023, Hayk Hakobyan
3
+ Copyright (c) 2024, Hayk Hakobyan
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without
6
6
  modification, are permitted provided that the following conditions are met:
@@ -1,13 +1,13 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: myplotlib
3
- Version: 1.2.0
3
+ Version: 1.4.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) 2023, Hayk Hakobyan
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:
@@ -47,7 +47,7 @@ Classifier: Programming Language :: Python :: 3.11
47
47
  Classifier: Programming Language :: Python :: 3.12
48
48
  Classifier: Topic :: Scientific/Engineering :: Visualization
49
49
  Requires-Python: >=3.8
50
- Requires-Dist: matplotlib>=3.0.0
50
+ Requires-Dist: matplotlib>=3.5.0
51
51
  Requires-Dist: numba>=0.57.0
52
52
  Requires-Dist: numpy
53
53
  Description-Content-Type: text/markdown
@@ -67,10 +67,11 @@ pip install myplotlib
67
67
  ```python
68
68
  # initialize style:
69
69
  import myplotlib
70
- myplotlib.load(style=..., flavor=...)
70
+ myplotlib.load(style=..., flavor=..., usetex=...)
71
71
  # style can be [None | `fancy` | `mono` | `hershey`]
72
72
  # flavor can be [None | `light` | `dark`]
73
- # if not specified defaults to `style = None, flavor = None`
73
+ # usetex can be [True | False]
74
+ # if not specified defaults to `style = None, flavor = None, usetex = True`
74
75
 
75
76
  # auxiliary functions for plotting:
76
77
  import myplotlib.plots as myplt
@@ -88,7 +89,7 @@ for more usage examples checkout the `tests/` submodule.
88
89
  ### requirements
89
90
 
90
91
  * `python >= 3.8`
91
- * `matplotlib >= 3.0.0`, `numpy`
92
+ * `matplotlib >= 3.5.0`, `numpy`
92
93
  * `latex` (used for `style="fancy"` only)
93
94
  * `numba>=0.57.0`
94
95
 
@@ -13,10 +13,11 @@ pip install myplotlib
13
13
  ```python
14
14
  # initialize style:
15
15
  import myplotlib
16
- myplotlib.load(style=..., flavor=...)
16
+ myplotlib.load(style=..., flavor=..., usetex=...)
17
17
  # style can be [None | `fancy` | `mono` | `hershey`]
18
18
  # flavor can be [None | `light` | `dark`]
19
- # if not specified defaults to `style = None, flavor = None`
19
+ # usetex can be [True | False]
20
+ # if not specified defaults to `style = None, flavor = None, usetex = True`
20
21
 
21
22
  # auxiliary functions for plotting:
22
23
  import myplotlib.plots as myplt
@@ -34,7 +35,7 @@ for more usage examples checkout the `tests/` submodule.
34
35
  ### requirements
35
36
 
36
37
  * `python >= 3.8`
37
- * `matplotlib >= 3.0.0`, `numpy`
38
+ * `matplotlib >= 3.5.0`, `numpy`
38
39
  * `latex` (used for `style="fancy"` only)
39
40
  * `numba>=0.57.0`
40
41
 
@@ -1,4 +1,4 @@
1
- __version__ = "1.2.0"
1
+ __version__ = "1.4.0"
2
2
 
3
3
  CUSTOM_CMAPS = []
4
4
 
@@ -27,27 +27,26 @@ def __InstallCmapFromCSV(csv):
27
27
  import os
28
28
  import numpy as np
29
29
  import matplotlib as mpl
30
- import matplotlib.pyplot as plt
31
30
 
32
31
  cmap = os.path.splitext(os.path.basename(csv))[0]
33
32
  cmap_data = np.loadtxt(csv, delimiter=",")
34
- if cmap not in plt.colormaps():
33
+ if cmap not in mpl.colormaps.keys():
35
34
  CUSTOM_CMAPS.append(cmap)
36
35
  mpl_data = __RGBToPyCmap(cmap_data)
37
- plt.register_cmap(
36
+ mpl.colormaps.register(
38
37
  cmap=mpl.colors.LinearSegmentedColormap(cmap, mpl_data, cmap_data.shape[0])
39
38
  )
40
39
  cmap = f"{cmap}_r"
41
- if cmap not in plt.colormaps():
40
+ if cmap not in mpl.colormaps.keys():
42
41
  mpl_data_r = __RGBToPyCmap(cmap_data[::-1, :])
43
- plt.register_cmap(
42
+ mpl.colormaps.register(
44
43
  cmap=mpl.colors.LinearSegmentedColormap(
45
44
  cmap, mpl_data_r, cmap_data.shape[0]
46
45
  )
47
46
  )
48
47
 
49
48
 
50
- def load(style=None, flavor="light"):
49
+ def load(style=None, flavor="light", usetex=True):
51
50
  """
52
51
  `myplotlib.load`
53
52
 
@@ -56,12 +55,15 @@ def load(style=None, flavor="light"):
56
55
  args
57
56
  ----------
58
57
  style [None] ............. : style to load (options: None, 'fancy', 'mono', 'hershey')
59
- flavor ['light'] ............ : color flavor to load (options: 'light', 'dark')
58
+ flavor ['light'] ......... : color flavor to load (options: 'light', 'dark')
59
+ usetex [True] ............ : whether to use LaTeX (True/False)
60
60
  """
61
61
  import os
62
62
  from matplotlib import font_manager
63
63
  import matplotlib.pyplot as plt
64
64
 
65
+ assert usetex or style != "fancy", "fancy style requires usetex=True"
66
+
65
67
  CMAP_DIR = os.path.join(os.path.dirname(__file__), "assets/colormaps")
66
68
  CMAPS = os.listdir(CMAP_DIR)
67
69
  for cmap in CMAPS:
@@ -76,3 +78,8 @@ def load(style=None, flavor="light"):
76
78
  os.path.dirname(__file__), f"assets/{style}.{flavor}.mplstyle"
77
79
  )
78
80
  plt.style.use(MPLSTYLE_FILE)
81
+ if usetex and not style == "fancy":
82
+ LATEXSTILE_FILE = os.path.join(
83
+ os.path.dirname(__file__), f"assets/latex.mplstyle"
84
+ )
85
+ plt.style.use(LATEXSTILE_FILE)
@@ -0,0 +1,2 @@
1
+ text.usetex: True
2
+ text.latex.preamble: \usepackage{amsmath,bm,xcolor}
@@ -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.scatter`
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.scatter`
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
- **kwargs .................... : standard matplotlib kwargs passed to `ax.scatter`
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,20 @@ 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("right", size=cbar, pad=cbar_pad)
245
- colorbar = plt.colorbar(ax.get_images()[0], cax=cax)
249
+ cax = divider.append_axes(cbar_pos, size=cbar, pad=cbar_pad)
250
+ colorbar = plt.colorbar(ax.get_images()[0], cax=cax,
251
+ orientation="vertical" if cbar_pos in ["left", "right"] else "horizontal")
252
+ if cbar_pos == "left":
253
+ cax.yaxis.set_ticks_position("left")
254
+ cax.yaxis.set_label_position("left")
255
+ ax.yaxis.set_ticks_position("right")
256
+ ax.yaxis.set_label_position("right")
257
+ if cbar_pos == "top":
258
+ cax.xaxis.set_ticks_position("top")
259
+ cax.xaxis.set_label_position("top")
260
+ if cbar_pos == "bottom":
261
+ ax.xaxis.set_ticks_position("top")
262
+ ax.xaxis.set_label_position("top")
246
263
  return colorbar
247
264
  else:
248
265
  return None
@@ -302,7 +319,7 @@ def plotVectorField(
302
319
  padx [0], pady [0] .......... : add whitespace to axes in each direction (0 = no additional space)
303
320
  cbar ['5%'] ................. : size of the colorbar in percent of x-axis (None = no colorbar)
304
321
  cbar_pad [0.05] ............. : padding of the colorbar
305
- **kwargs .................... : standard matplotlib kwargs passed to `ax.scatter`
322
+ **kwargs .................... : standard matplotlib kwargs passed to `ax.imshow`
306
323
  """
307
324
  import myplotlib.tools.lic as lic
308
325
  import matplotlib
@@ -336,7 +353,7 @@ def plotVectorField(
336
353
  * np.abs(weights - np.average(weights)) ** lic_contrast
337
354
  )
338
355
  colors = matplotlib.colors.Normalize(None, None)(_)
339
- colors = plt.cm.get_cmap(lic_cmap)(colors)
356
+ colors = matplotlib.colormaps[lic_cmap](colors)
340
357
  colors[..., -1] = alphas
341
358
 
342
359
  colorbar = plot2d(
Binary file
@@ -11,7 +11,7 @@ if __name__ == "__main__":
11
11
  for st, fl in [
12
12
  f.replace(".mplstyle", "").split(".")
13
13
  for f in os.listdir("myplotlib/assets")
14
- if f.endswith(".mplstyle")
14
+ if f.endswith(".mplstyle") and f.count(".") == 2
15
15
  ]:
16
16
  mpl.rcParams.update(mpl.rcParamsDefault)
17
17
  myplotlib.load(st, fl)
Binary file
Binary file
Binary file
Binary file
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  name = "myplotlib"
7
7
  dynamic = ["version"]
8
- dependencies = ["matplotlib>=3.0.0", "numpy", "numba>=0.57.0"]
8
+ dependencies = ["matplotlib>=3.5.0", "numpy", "numba>=0.57.0"]
9
9
  requires-python = ">=3.8"
10
10
  authors = [{ name = "Hayk", email = "haykh.astro@gmail.com" }]
11
11
  maintainers = [{ name = "Hayk", email = "haykh.astro@gmail.com" }]
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
File without changes
File without changes
File without changes
@@ -1,7 +1,3 @@
1
- # `fancy.light`
2
-
3
- ![fancy_light](fancy_light.jpg)
4
-
5
1
  # `mono.dark`
6
2
 
7
3
  ![mono_dark](mono_dark.jpg)
@@ -10,10 +6,6 @@
10
6
 
11
7
  ![mono_light](mono_light.jpg)
12
8
 
13
- # `fancy.dark`
14
-
15
- ![fancy_dark](fancy_dark.jpg)
16
-
17
9
  # `hershey.light`
18
10
 
19
11
  ![hershey_light](hershey_light.jpg)
@@ -22,6 +14,14 @@
22
14
 
23
15
  ![hershey_dark](hershey_dark.jpg)
24
16
 
17
+ # `fancy.light`
18
+
19
+ ![fancy_light](fancy_light.jpg)
20
+
21
+ # `fancy.dark`
22
+
23
+ ![fancy_dark](fancy_dark.jpg)
24
+
25
25
  # `None`
26
26
 
27
27
  ![None](None.jpg)