maxplotlibx 0.1.2__tar.gz → 0.1.3__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.
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/PKG-INFO +1 -1
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/pyproject.toml +1 -1
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/backends/matplotlib/utils.py +22 -4
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/canvas/canvas.py +35 -5
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlibx.egg-info/PKG-INFO +1 -1
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/LICENSE +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/README.md +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/setup.cfg +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/backends/plotly/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/backends/plotly/utils.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/canvas/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/colors/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/colors/colors.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/linestyle/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/linestyle/linestyle.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/objects/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/objects/node.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/objects/path.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/subfigure/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/subfigure/line_plot.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/subfigure/subfigure.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/tests/test_canvas.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/tests/test_imports.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/tests/test_plot.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/utils/__init__.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlib/utils/options.py +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlibx.egg-info/SOURCES.txt +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlibx.egg-info/dependency_links.txt +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlibx.egg-info/requires.txt +0 -0
- {maxplotlibx-0.1.2 → maxplotlibx-0.1.3}/src/maxplotlibx.egg-info/top_level.txt +0 -0
|
@@ -56,18 +56,30 @@ def convert_to_inches(length_str):
|
|
|
56
56
|
return quantity.to("inch").magnitude # Convert to inches
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
def _2pt(width, dpi=300):
|
|
59
|
+
def _2pt(width, dpi=300, verbose: bool = False):
|
|
60
|
+
if verbose:
|
|
61
|
+
print(f"Converting width: {width} to points with dpi={dpi}")
|
|
62
|
+
|
|
60
63
|
if isinstance(width, (int, float)):
|
|
61
64
|
return width
|
|
62
65
|
elif isinstance(width, str):
|
|
63
66
|
length_in = convert_to_inches(width)
|
|
64
67
|
length_pt = length_in * dpi
|
|
68
|
+
if verbose:
|
|
69
|
+
print(f"Converted length: {length_in} inches = {length_pt} points")
|
|
65
70
|
return length_pt
|
|
66
71
|
else:
|
|
67
72
|
raise NotImplementedError
|
|
68
73
|
|
|
69
74
|
|
|
70
|
-
|
|
75
|
+
# TODO: Use literal types for width and ratio
|
|
76
|
+
def set_size(
|
|
77
|
+
width: str,
|
|
78
|
+
fraction: int | float = 1,
|
|
79
|
+
ratio: str | int | float = "golden",
|
|
80
|
+
dpi=300,
|
|
81
|
+
verbose: bool = False,
|
|
82
|
+
) -> tuple:
|
|
71
83
|
"""
|
|
72
84
|
Sets figure dimensions to avoid scaling in LaTeX.
|
|
73
85
|
"""
|
|
@@ -76,9 +88,11 @@ def set_size(width, fraction=1, ratio="golden", dpi=300):
|
|
|
76
88
|
elif width == "beamer":
|
|
77
89
|
width_pt = 307.28987
|
|
78
90
|
else:
|
|
79
|
-
width_pt = _2pt(width=width, dpi=dpi)
|
|
91
|
+
width_pt = _2pt(width=width, dpi=dpi, verbose=verbose)
|
|
80
92
|
|
|
81
93
|
fig_width_pt = width_pt * fraction
|
|
94
|
+
inches_per_pt = 1 / 72.27
|
|
95
|
+
# fig_width_pt = width_pt * fraction
|
|
82
96
|
# inches_per_pt = 1 / 72.27
|
|
83
97
|
|
|
84
98
|
# Calculate the figure height based on the desired ratio
|
|
@@ -91,7 +105,11 @@ def set_size(width, fraction=1, ratio="golden", dpi=300):
|
|
|
91
105
|
fig_height_pt = fig_width_pt * ratio
|
|
92
106
|
else:
|
|
93
107
|
raise ValueError("Invalid ratio specified.")
|
|
94
|
-
|
|
108
|
+
|
|
109
|
+
# Convert from points to inches for matplotlib
|
|
110
|
+
fig_width_in = fig_width_pt * inches_per_pt
|
|
111
|
+
fig_height_in = fig_height_pt * inches_per_pt
|
|
112
|
+
fig_dim = (fig_width_in, fig_height_in)
|
|
95
113
|
return fig_dim
|
|
96
114
|
|
|
97
115
|
|
|
@@ -267,9 +267,17 @@ class Canvas:
|
|
|
267
267
|
backend: Backends = "matplotlib",
|
|
268
268
|
savefig=False,
|
|
269
269
|
layers=None,
|
|
270
|
+
verbose: bool = False,
|
|
270
271
|
):
|
|
272
|
+
if verbose:
|
|
273
|
+
print(f"Plotting figure using backend: {backend}")
|
|
274
|
+
|
|
271
275
|
if backend == "matplotlib":
|
|
272
|
-
return self.plot_matplotlib(
|
|
276
|
+
return self.plot_matplotlib(
|
|
277
|
+
savefig=savefig,
|
|
278
|
+
layers=layers,
|
|
279
|
+
verbose=verbose,
|
|
280
|
+
)
|
|
273
281
|
elif backend == "plotly":
|
|
274
282
|
return self.plot_plotly(savefig=savefig)
|
|
275
283
|
elif backend == "tikzpics":
|
|
@@ -280,10 +288,19 @@ class Canvas:
|
|
|
280
288
|
def show(
|
|
281
289
|
self,
|
|
282
290
|
backend: Backends = "matplotlib",
|
|
291
|
+
verbose: bool = False,
|
|
283
292
|
):
|
|
293
|
+
if verbose:
|
|
294
|
+
print(f"Showing figure using backend: {backend}")
|
|
295
|
+
|
|
284
296
|
if backend == "matplotlib":
|
|
285
|
-
self.plot(
|
|
286
|
-
|
|
297
|
+
self.plot(
|
|
298
|
+
backend="matplotlib",
|
|
299
|
+
savefig=False,
|
|
300
|
+
layers=None,
|
|
301
|
+
verbose=verbose,
|
|
302
|
+
)
|
|
303
|
+
# self._matplotlib_fig.show()
|
|
287
304
|
elif backend == "plotly":
|
|
288
305
|
self.plot_plotly(savefig=False)
|
|
289
306
|
elif backend == "tikzpics":
|
|
@@ -292,13 +309,21 @@ class Canvas:
|
|
|
292
309
|
else:
|
|
293
310
|
raise ValueError("Invalid backend")
|
|
294
311
|
|
|
295
|
-
def plot_matplotlib(
|
|
312
|
+
def plot_matplotlib(
|
|
313
|
+
self,
|
|
314
|
+
savefig: bool = False,
|
|
315
|
+
layers: list | None = None,
|
|
316
|
+
usetex: bool = False,
|
|
317
|
+
verbose: bool = False,
|
|
318
|
+
):
|
|
296
319
|
"""
|
|
297
320
|
Generate and optionally display the subplots.
|
|
298
321
|
|
|
299
322
|
Parameters:
|
|
300
323
|
filename (str, optional): Filename to save the figure.
|
|
301
324
|
"""
|
|
325
|
+
if verbose:
|
|
326
|
+
print("Generating Matplotlib figure...")
|
|
302
327
|
|
|
303
328
|
tex_fonts = setup_tex_fonts(fontsize=self.fontsize, usetex=usetex)
|
|
304
329
|
|
|
@@ -309,7 +334,9 @@ class Canvas:
|
|
|
309
334
|
grid_alpha=1.0,
|
|
310
335
|
grid_linestyle="dotted",
|
|
311
336
|
)
|
|
312
|
-
|
|
337
|
+
if verbose:
|
|
338
|
+
print("Plot style set up.")
|
|
339
|
+
print(f"{self._figsize = } {self._width = } {self._ratio = }")
|
|
313
340
|
if self._figsize is not None:
|
|
314
341
|
fig_width, fig_height = self._figsize
|
|
315
342
|
else:
|
|
@@ -317,7 +344,10 @@ class Canvas:
|
|
|
317
344
|
width=self._width,
|
|
318
345
|
ratio=self._ratio,
|
|
319
346
|
dpi=self.dpi,
|
|
347
|
+
verbose=verbose,
|
|
320
348
|
)
|
|
349
|
+
if verbose:
|
|
350
|
+
print(f"Figure size: {fig_width} x {fig_height} points")
|
|
321
351
|
|
|
322
352
|
fig, axes = plt.subplots(
|
|
323
353
|
self.nrows,
|
|
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
|