maxplotlibx 0.1__tar.gz → 0.1.1__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 (34) hide show
  1. {maxplotlibx-0.1/src/maxplotlibx.egg-info → maxplotlibx-0.1.1}/PKG-INFO +1 -3
  2. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/README.md +0 -2
  3. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/pyproject.toml +10 -1
  4. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/canvas/canvas.py +51 -26
  5. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/subfigure/line_plot.py +10 -5
  6. maxplotlibx-0.1.1/src/maxplotlib/utils/__init__.py +0 -0
  7. maxplotlibx-0.1.1/src/maxplotlib/utils/options.py +3 -0
  8. {maxplotlibx-0.1 → maxplotlibx-0.1.1/src/maxplotlibx.egg-info}/PKG-INFO +1 -3
  9. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlibx.egg-info/SOURCES.txt +2 -0
  10. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/LICENSE +0 -0
  11. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/setup.cfg +0 -0
  12. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/__init__.py +0 -0
  13. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/backends/matplotlib/utils.py +0 -0
  14. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/backends/matplotlib/utils_old.py +0 -0
  15. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/backends/plotly/__init__.py +0 -0
  16. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/backends/plotly/utils.py +0 -0
  17. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/canvas/__init__.py +0 -0
  18. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/colors/__init__.py +0 -0
  19. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/colors/colors.py +0 -0
  20. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/linestyle/__init__.py +0 -0
  21. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/linestyle/linestyle.py +0 -0
  22. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/objects/__init__.py +0 -0
  23. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/objects/layer.py +0 -0
  24. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/objects/node.py +0 -0
  25. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/objects/path.py +0 -0
  26. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/subfigure/__init__.py +0 -0
  27. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/subfigure/subfigure.py +0 -0
  28. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/subfigure/tikz_figure.py +0 -0
  29. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/tests/test_canvas.py +0 -0
  30. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/tests/test_imports.py +0 -0
  31. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlib/tests/test_plot.py +0 -0
  32. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlibx.egg-info/dependency_links.txt +0 -0
  33. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlibx.egg-info/requires.txt +0 -0
  34. {maxplotlibx-0.1 → maxplotlibx-0.1.1}/src/maxplotlibx.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maxplotlibx
3
- Version: 0.1
3
+ Version: 0.1.1
4
4
  Summary: A reproducible plotting module with various backends and export options.
5
5
  Author: Max
6
6
  Project-URL: Source, https://github.com/max-models/maxplotlib
@@ -37,8 +37,6 @@ Dynamic: license-file
37
37
 
38
38
  This is a wrapper for matplotlib so I can produce figures with consistent formatting. It also has some pretty nice additions such as using layers and exporting to tikz.
39
39
 
40
- Related packages: [maxtikzlib](https://github.com/max-models/maxtikzlib) and [maxtexlib](https://github.com/max-models/maxtexlib).
41
-
42
40
  ## Install
43
41
 
44
42
  Create and activate python environment
@@ -2,8 +2,6 @@
2
2
 
3
3
  This is a wrapper for matplotlib so I can produce figures with consistent formatting. It also has some pretty nice additions such as using layers and exporting to tikz.
4
4
 
5
- Related packages: [maxtikzlib](https://github.com/max-models/maxtikzlib) and [maxtexlib](https://github.com/max-models/maxtexlib).
6
-
7
5
  ## Install
8
6
 
9
7
  Create and activate python environment
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maxplotlibx"
7
- version = "0.1"
7
+ version = "0.1.1"
8
8
  description = "A reproducible plotting module with various backends and export options."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -47,3 +47,12 @@ dev = [
47
47
 
48
48
  [tool.setuptools.packages.find]
49
49
  where = ["src"]
50
+
51
+ [tool.black]
52
+ line-length = 88
53
+
54
+ [tool.ruff]
55
+ line-length = 88
56
+
57
+ [tool.isort]
58
+ profile = "black"
@@ -1,16 +1,35 @@
1
1
  import os
2
+ from typing import Dict
2
3
 
3
4
  import matplotlib.pyplot as plt
4
5
  import plotly.graph_objects as go
5
6
  from plotly.subplots import make_subplots
6
7
 
7
- import maxplotlib.backends.matplotlib.utils as plt_utils
8
+ from maxplotlib.backends.matplotlib.utils import (
9
+ set_size,
10
+ setup_plotstyle,
11
+ setup_tex_fonts,
12
+ )
8
13
  from maxplotlib.subfigure.line_plot import LinePlot
9
14
  from maxplotlib.subfigure.tikz_figure import TikzFigure
15
+ from maxplotlib.utils.options import Backends
10
16
 
11
17
 
12
18
  class Canvas:
13
- def __init__(self, **kwargs):
19
+ def __init__(
20
+ self,
21
+ nrows: int = 1,
22
+ ncols: int = 1,
23
+ figsize: tuple | None = None,
24
+ caption: str | None = None,
25
+ description: str | None = None,
26
+ label: str | None = None,
27
+ fontsize: int = 14,
28
+ dpi: int = 300,
29
+ width: str = "17cm",
30
+ ratio: str = "golden", # TODO Add literal
31
+ gridspec_kw: Dict = {"wspace": 0.08, "hspace": 0.1},
32
+ ):
14
33
  """
15
34
  Initialize the Canvas class for multiple subplots.
16
35
 
@@ -18,21 +37,27 @@ class Canvas:
18
37
  nrows (int): Number of subplot rows. Default is 1.
19
38
  ncols (int): Number of subplot columns. Default is 1.
20
39
  figsize (tuple): Figure size.
40
+ caption (str): Caption for the figure.
41
+ description (str): Description for the figure.
42
+ label (str): Label for the figure.
43
+ fontsize (int): Font size. Default is 14.
44
+ dpi (int): DPI for the figure. Default is 300.
45
+ width (str): Width of the figure. Default is "17cm".
46
+ ratio (str): Aspect ratio. Default is "golden".
47
+ gridspec_kw (dict): Gridspec keyword arguments. Default is {"wspace": 0.08, "hspace": 0.1}.
21
48
  """
22
49
 
23
- # nrows=1, ncols=1, caption=None, description=None, label=None, figsize=None
24
- self._nrows = kwargs.get("nrows", 1)
25
- self._ncols = kwargs.get("ncols", 1)
26
- self._figsize = kwargs.get("figsize", None)
27
- self._caption = kwargs.get("caption", None)
28
- self._description = kwargs.get("description", None)
29
- self._label = kwargs.get("label", None)
30
- self._fontsize = kwargs.get("fontsize", 14)
31
- self._dpi = kwargs.get("dpi", 300)
32
- # self._width = kwargs.get("width", 426.79135)
33
- self._width = kwargs.get("width", "17cm")
34
- self._ratio = kwargs.get("ratio", "golden")
35
- self._gridspec_kw = kwargs.get("gridspec_kw", {"wspace": 0.08, "hspace": 0.1})
50
+ self._nrows = nrows
51
+ self._ncols = ncols
52
+ self._figsize = figsize
53
+ self._caption = caption
54
+ self._description = description
55
+ self._label = label
56
+ self._fontsize = fontsize
57
+ self._dpi = dpi
58
+ self._width = width
59
+ self._ratio = ratio
60
+ self._gridspec_kw = gridspec_kw
36
61
  self._plotted = False
37
62
 
38
63
  # Dictionary to store lines for each subplot
@@ -196,11 +221,11 @@ class Canvas:
196
221
  def savefig(
197
222
  self,
198
223
  filename,
199
- backend="matplotlib",
200
- layers=None,
201
- layer_by_layer=False,
202
- verbose=False,
203
- plot=True,
224
+ backend: Backends = "matplotlib",
225
+ layers: list | None = None,
226
+ layer_by_layer: bool = False,
227
+ verbose: bool = False,
228
+ plot: bool = True,
204
229
  ):
205
230
  filename_no_extension, extension = os.path.splitext(filename)
206
231
  if backend == "matplotlib":
@@ -238,7 +263,7 @@ class Canvas:
238
263
  if verbose:
239
264
  print(f"Saved {full_filepath}")
240
265
 
241
- def plot(self, backend="matplotlib", savefig=False, layers=None):
266
+ def plot(self, backend: Backends = "matplotlib", savefig=False, layers=None):
242
267
  if backend == "matplotlib":
243
268
  return self.plot_matplotlib(savefig=savefig, layers=layers)
244
269
  elif backend == "plotly":
@@ -263,9 +288,9 @@ class Canvas:
263
288
  filename (str, optional): Filename to save the figure.
264
289
  """
265
290
 
266
- tex_fonts = plt_utils.setup_tex_fonts(fontsize=self.fontsize, usetex=usetex)
291
+ tex_fonts = setup_tex_fonts(fontsize=self.fontsize, usetex=usetex)
267
292
 
268
- plt_utils.setup_plotstyle(
293
+ setup_plotstyle(
269
294
  tex_fonts=tex_fonts,
270
295
  axes_grid=True,
271
296
  axes_grid_which="major",
@@ -276,7 +301,7 @@ class Canvas:
276
301
  if self._figsize is not None:
277
302
  fig_width, fig_height = self._figsize
278
303
  else:
279
- fig_width, fig_height = plt_utils.set_size(
304
+ fig_width, fig_height = set_size(
280
305
  width=self._width,
281
306
  ratio=self._ratio,
282
307
  dpi=self.dpi,
@@ -313,7 +338,7 @@ class Canvas:
313
338
  savefig (str, optional): Filename to save the figure if provided.
314
339
  """
315
340
 
316
- tex_fonts = plt_utils.setup_tex_fonts(
341
+ tex_fonts = setup_tex_fonts(
317
342
  fontsize=self.fontsize,
318
343
  usetex=usetex,
319
344
  ) # adjust or redefine for Plotly if needed
@@ -322,7 +347,7 @@ class Canvas:
322
347
  if self._figsize is not None:
323
348
  fig_width, fig_height = self._figsize
324
349
  else:
325
- fig_width, fig_height = plt_utils.set_size(
350
+ fig_width, fig_height = set_size(
326
351
  width=self._width,
327
352
  ratio=self._ratio,
328
353
  )
@@ -163,7 +163,12 @@ class LinePlot:
163
163
  layers.append(layer_name)
164
164
  return layers
165
165
 
166
- def plot_matplotlib(self, ax, layers=None):
166
+ def plot_matplotlib(
167
+ self,
168
+ ax,
169
+ layers=None,
170
+ verbose: bool = False,
171
+ ):
167
172
  """
168
173
  Plot all lines on the provided axis.
169
174
 
@@ -210,13 +215,13 @@ class LinePlot:
210
215
  ax.legend()
211
216
  if self._grid:
212
217
  ax.grid()
213
- if self.xmin:
218
+ if self.xmin is not None:
214
219
  ax.axis(xmin=self.xmin)
215
- if self.xmax:
220
+ if self.xmax is not None:
216
221
  ax.axis(xmax=self.xmax)
217
- if self.ymin:
222
+ if self.ymin is not None:
218
223
  ax.axis(ymin=self.ymin)
219
- if self.ymax:
224
+ if self.ymax is not None:
220
225
  ax.axis(ymax=self.ymax)
221
226
 
222
227
  def plot_plotly(self):
File without changes
@@ -0,0 +1,3 @@
1
+ from typing import Literal
2
+
3
+ Backends = Literal["matplotlib", "plotly"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maxplotlibx
3
- Version: 0.1
3
+ Version: 0.1.1
4
4
  Summary: A reproducible plotting module with various backends and export options.
5
5
  Author: Max
6
6
  Project-URL: Source, https://github.com/max-models/maxplotlib
@@ -37,8 +37,6 @@ Dynamic: license-file
37
37
 
38
38
  This is a wrapper for matplotlib so I can produce figures with consistent formatting. It also has some pretty nice additions such as using layers and exporting to tikz.
39
39
 
40
- Related packages: [maxtikzlib](https://github.com/max-models/maxtikzlib) and [maxtexlib](https://github.com/max-models/maxtexlib).
41
-
42
40
  ## Install
43
41
 
44
42
  Create and activate python environment
@@ -23,6 +23,8 @@ src/maxplotlib/subfigure/tikz_figure.py
23
23
  src/maxplotlib/tests/test_canvas.py
24
24
  src/maxplotlib/tests/test_imports.py
25
25
  src/maxplotlib/tests/test_plot.py
26
+ src/maxplotlib/utils/__init__.py
27
+ src/maxplotlib/utils/options.py
26
28
  src/maxplotlibx.egg-info/PKG-INFO
27
29
  src/maxplotlibx.egg-info/SOURCES.txt
28
30
  src/maxplotlibx.egg-info/dependency_links.txt
File without changes
File without changes