maxplotlibx 0.1.2__py3-none-any.whl → 0.1.4__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.
@@ -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
- def set_size(width, fraction=1, ratio="golden", dpi=300):
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
- fig_dim = (fig_width_pt, fig_height_pt)
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