plotlp 0.1.18__tar.gz → 0.1.19__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 (85) hide show
  1. {plotlp-0.1.18 → plotlp-0.1.19}/PKG-INFO +1 -1
  2. {plotlp-0.1.18 → plotlp-0.1.19}/pyproject.toml +1 -1
  3. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledAxes_LP/StyledAxes.py +24 -1
  4. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledFigure_LP/StyledFigure.py +32 -0
  5. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/figure_LP/test_figure.py +6 -4
  6. {plotlp-0.1.18 → plotlp-0.1.19}/README.md +0 -0
  7. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/.docignore +0 -0
  8. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/__init__.py +0 -0
  9. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledAxes_LP/__init__.py +0 -0
  10. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledAxes_LP/_doctype.txt +0 -0
  11. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledAxes_LP/_functions/__init__.py +0 -0
  12. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledAxes_LP/_functions/__template__.py +0 -0
  13. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledAxes_LP/_functions/scalebar.py +0 -0
  14. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledAxes_LP/test_StyledAxes.py +0 -0
  15. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledFigure_LP/__init__.py +0 -0
  16. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledFigure_LP/_doctype.txt +0 -0
  17. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledFigure_LP/_functions/__init__.py +0 -0
  18. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledFigure_LP/_functions/__template__.py +0 -0
  19. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/StyledFigure_LP/test_StyledFigure.py +0 -0
  20. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/__init__.py +0 -0
  21. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/cmap_LP/__init__.py +0 -0
  22. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/cmap_LP/_doctype.txt +0 -0
  23. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/cmap_LP/_functions/__init__.py +0 -0
  24. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/cmap_LP/_functions/__template__.py +0 -0
  25. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/cmap_LP/cmap.py +0 -0
  26. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/cmap_LP/test_cmap.py +0 -0
  27. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/color_LP/__init__.py +0 -0
  28. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/color_LP/_doctype.txt +0 -0
  29. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/color_LP/_functions/__init__.py +0 -0
  30. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/color_LP/_functions/__template__.py +0 -0
  31. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/color_LP/color.py +0 -0
  32. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/color_LP/test_color.py +0 -0
  33. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/compare_distributions_LP/__init__.py +0 -0
  34. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/compare_distributions_LP/_doctype.txt +0 -0
  35. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/compare_distributions_LP/_functions/__init__.py +0 -0
  36. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/compare_distributions_LP/_functions/__template__.py +0 -0
  37. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/compare_distributions_LP/compare_distributions.py +0 -0
  38. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/compare_distributions_LP/test_compare_distributions.py +0 -0
  39. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/figure_LP/__init__.py +0 -0
  40. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/figure_LP/_doctype.txt +0 -0
  41. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/figure_LP/_functions/__init__.py +0 -0
  42. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/figure_LP/_functions/__template__.py +0 -0
  43. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/figure_LP/figure.py +0 -0
  44. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/gridsubplots_LP/__init__.py +0 -0
  45. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/gridsubplots_LP/_doctype.txt +0 -0
  46. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/gridsubplots_LP/_functions/__init__.py +0 -0
  47. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/gridsubplots_LP/_functions/__template__.py +0 -0
  48. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/gridsubplots_LP/gridsubplots.py +0 -0
  49. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/gridsubplots_LP/test_gridsubplots.py +0 -0
  50. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/imgfigure_LP/__init__.py +0 -0
  51. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/imgfigure_LP/_doctype.txt +0 -0
  52. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/imgfigure_LP/_functions/__init__.py +0 -0
  53. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/imgfigure_LP/_functions/__template__.py +0 -0
  54. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/imgfigure_LP/imgfigure.py +0 -0
  55. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/imgfigure_LP/test_imgfigure.py +0 -0
  56. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/make_animation_LP/__init__.py +0 -0
  57. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/make_animation_LP/_doctype.txt +0 -0
  58. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/make_animation_LP/_functions/__init__.py +0 -0
  59. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/make_animation_LP/_functions/__template__.py +0 -0
  60. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/make_animation_LP/make_animation.py +0 -0
  61. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/make_animation_LP/test_make_animation.py +0 -0
  62. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/plt_LP/__init__.py +0 -0
  63. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/plt_LP/_doctype.txt +0 -0
  64. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/plt_LP/_functions/__init__.py +0 -0
  65. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/plt_LP/_functions/__template__.py +0 -0
  66. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/plt_LP/plt.py +0 -0
  67. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/plt_LP/test_plt.py +0 -0
  68. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/__init__.py +0 -0
  69. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/_doctype.txt +0 -0
  70. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/_functions/__init__.py +0 -0
  71. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/_functions/__template__.py +0 -0
  72. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/_functions/_darkLP.py +0 -0
  73. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/_functions/_default.py +0 -0
  74. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/_functions/_lightLP.py +0 -0
  75. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/_functions/_styleLP.py +0 -0
  76. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/style.py +0 -0
  77. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/style_LP/test_style.py +0 -0
  78. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/subplots_LP/__init__.py +0 -0
  79. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/subplots_LP/_doctype.txt +0 -0
  80. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/subplots_LP/_functions/__init__.py +0 -0
  81. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/subplots_LP/_functions/__template__.py +0 -0
  82. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/subplots_LP/subplots.py +0 -0
  83. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/modules/subplots_LP/test_subplots.py +0 -0
  84. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/py.typed +0 -0
  85. {plotlp-0.1.18 → plotlp-0.1.19}/src/plotlp/routines/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: plotlp
3
- Version: 0.1.18
3
+ Version: 0.1.19
4
4
  Summary: A library wrapper around matplotlib for custom plots.
5
5
  Requires-Dist: corelp
6
6
  Requires-Dist: cycler
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "plotlp"
3
- version = "0.1.18"
3
+ version = "0.1.19"
4
4
  description = "A library wrapper around matplotlib for custom plots."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -133,6 +133,7 @@ class StyledAxes(Axes) :
133
133
  if self.polish_imscale : self.imscale()
134
134
  if self.polish_noborders : self.noborders()
135
135
  if self.polish_equiscale : self.equiscale()
136
+ if self.polish_figscale : self.figscale()
136
137
 
137
138
  # grids
138
139
  @prop()
@@ -179,6 +180,28 @@ class StyledAxes(Axes) :
179
180
  with plt.style.context(self.style) :
180
181
  self.set_aspect(aspect='equal', adjustable='box')
181
182
 
183
+ # figscale
184
+ @prop()
185
+ def polish_figscale(self) :
186
+ return self.figure.naxes == 1 and not self.polish_imscale and self.polish_equiscale
187
+ def figscale(self) :
188
+ with plt.style.context(self.style) :
189
+ ratio = self.figure.figsize_ratio
190
+ xmin, xmax = self.get_xlim()
191
+ ymin, ymax = self.get_ylim()
192
+ dx, dy = xmax - xmin, ymax - ymin
193
+ x, y = (xmax + xmin) / 2, (ymax + ymin) / 2
194
+ if dx / dy != ratio :
195
+ _dx, _dy = ratio * dy, dx / ratio
196
+ dx = _dx if _dx > dx else dx
197
+ dy = _dy if _dy > dy else dy
198
+ xmin, xmax = x - dx/2, x + dx/2
199
+ ymin, ymax = y - dy/2, y + dy/2
200
+ if self.get_autoscalex_on() :
201
+ self.set_xlim(xmin, xmax)
202
+ if self.get_autoscaley_on() :
203
+ self.set_ylim(ymin, ymax)
204
+
182
205
 
183
206
 
184
207
  ### --- Regenerate parent class methods in the given style ---
@@ -189,7 +212,7 @@ def is_plottable(method_name, method_obj):
189
212
  """
190
213
  Returns True if this method should be wrapped automatically.
191
214
  """
192
- if hasattr(StyledAxes, method_name): # Already overriden
215
+ if method_name in StyledAxes.__dict__ : # Already overriden
193
216
  return False
194
217
  if method_name.startswith("_"): # private
195
218
  return False # handled separately
@@ -156,10 +156,15 @@ class StyledFigure(Figure) :
156
156
 
157
157
 
158
158
 
159
+ # Merging and splitting
159
160
  @property
160
161
  def merge(self):
161
162
  return _MergeIndexer(self)
162
163
 
164
+ @property
165
+ def split(self):
166
+ return _SplitIndexer(self)
167
+
163
168
  def _normalize_indices(self, idx, size):
164
169
  if isinstance(idx, slice):
165
170
  return list(range(*idx.indices(size)))
@@ -198,6 +203,17 @@ class StyledFigure(Figure) :
198
203
 
199
204
  return new_ax
200
205
 
206
+ def _split_axis(self, row, col, height, width):
207
+
208
+ if not hasattr(self, "_axes_grid"):
209
+ raise RuntimeError("merge only works with fig.subplots()")
210
+
211
+ grid = self._axes_grid
212
+ axes_to_merge = [grid[i, j] for i in row for j in col]
213
+
214
+ # TODO
215
+
216
+ return None
201
217
 
202
218
 
203
219
  # Paper index
@@ -351,6 +367,22 @@ class _MergeIndexer:
351
367
 
352
368
 
353
369
 
370
+ class _SplitIndexer:
371
+
372
+ def __init__(self, fig):
373
+ self.fig = fig
374
+
375
+ def __getitem__(self, key):
376
+
377
+ if not isinstance(key, tuple):
378
+ raise KeyError(f'Splitting figure axis should only be done with two coordinates, not {key}')
379
+
380
+ r, c, h, w = key
381
+
382
+ return self.fig._split_axis(r, c, h, w)
383
+
384
+
385
+
354
386
  # %% Test function run
355
387
  if __name__ == "__main__":
356
388
  from corelp import test
@@ -31,12 +31,14 @@ def test_plot() :
31
31
  y = x**2
32
32
  fig = figure(figsize_fact=(0.5,0.5), darkmode=True)
33
33
  fig.axis.plot(x, -y)
34
+ fig.axis.scatter(x, -y)
34
35
  plt.plot(x, y)
36
+ plt.scatter(x, y)
35
37
  plt.xlabel('x [ua]')
36
38
  fig.axis.set_ylabel('y [ua]')
37
39
  fig.title = 'test title'
38
- plt.savefig(path_png = debug_folder / 'plot_png', close=False)
39
- plt.savefig(path_pdf = debug_folder / 'plot_pdf', close=False)
40
+ fig.savefig(path_png = debug_folder / 'plot_png', close=False)
41
+ fig.savefig(path_pdf = debug_folder / 'plot_pdf', close=False)
40
42
  plt.savefig(debug_folder / 'plot_all')
41
43
 
42
44
  def test_imshow() :
@@ -50,8 +52,8 @@ def test_imshow() :
50
52
  fig = figure(figsize_ratio=4/3)
51
53
  fig.axis.imshow(img, barname='intensity')
52
54
  fig.title = 'test title'
53
- plt.savefig(path_png = debug_folder / 'imshow_png', close=False)
54
- plt.savefig(path_pdf = debug_folder / 'imshow_pdf', close=False)
55
+ fig.savefig(path_png = debug_folder / 'imshow_png', close=False)
56
+ fig.savefig(path_pdf = debug_folder / 'imshow_pdf', close=False)
55
57
  plt.savefig(debug_folder / 'imshow_all')
56
58
 
57
59
 
File without changes
File without changes
File without changes
File without changes