adopt-plot 0.0.1__tar.gz → 0.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: adopt-plot
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: A universal plotter for implicit functions using adaptive engine selection.
5
5
  Author: VartRusData
6
6
  License: BSD 3-Clause
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "adopt-plot"
7
- version = "0.0.1"
7
+ version = "0.0.3"
8
8
  description = "A universal plotter for implicit functions using adaptive engine selection."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -4,5 +4,7 @@
4
4
  class TooManyVariablesError(ValueError):
5
5
  """Исключение, возникающее при попытке построить график для более чем двух переменных."""
6
6
  pass
7
+ class PltNotFoundError(ModuleNotFoundError):
8
+ pass
7
9
  from .plot import AdoptPlot
8
10
  __all__ = ["AdoptPlot", "TooManyVariablesError"]
@@ -9,7 +9,7 @@ import re
9
9
  import sympy
10
10
 
11
11
 
12
- from . import TooManyVariablesError
12
+ from . import TooManyVariablesError, PltNotFoundError
13
13
 
14
14
  def get_all_sympy_function_names():
15
15
  """Собирает имена всех встроенных функций и констант SymPy."""
@@ -126,7 +126,7 @@ class AdoptPlot():
126
126
  self.points = points
127
127
  self.grid = grid
128
128
  self.interact = interact
129
- self.show = show
129
+ self.is_show = show
130
130
  self.limit = limit
131
131
  self.text_legend = text_legend
132
132
  # Получаем уравнения из поля ввода
@@ -263,10 +263,10 @@ class AdoptPlot():
263
263
  if self.lib == 'implicit' or (has_odz and self.lib is None):
264
264
  from sympy.plotting import plot_implicit
265
265
  if isinstance(self.limit, (int, float)):
266
- self.p = plot_implicit(self.eq, (var1, -self.limit, self.limit), (var2, -self.limit, self.limit), show=False, n=self.n, depth=self.depth)
266
+ self.p = plot_implicit(self.eq, (var1, -self.limit, self.limit), (var2, -self.limit, self.limit), show=False, n=self.n, depth=self.depth, line_color=self.color)
267
267
  elif isinstance(self.limit, tuple):
268
268
  if len(self.limit) == 4:
269
- self.p = plot_implicit(self.eq, (var1, *self.limit[:2]), (var2, *self.limit[2:]), show=False, n=self.n, depth=self.depth)
269
+ self.p = plot_implicit(self.eq, (var1, *self.limit[:2]), (var2, *self.limit[2:]), show=False, n=self.n, depth=self.depth, line_color=self.color)
270
270
  else:
271
271
  raise ValueError(f"Length mismatch (expected 4), got {len(self.limit)}.")
272
272
  else:
@@ -283,8 +283,7 @@ class AdoptPlot():
283
283
 
284
284
  # Три пустые линии для легенды (они не видны на графике, но создают текст в легенде)
285
285
  self.ax.plot([], [], ' ', label=f"${latex(self.eq)}$") # Красивое уравнение через LaTeX
286
- self.ax.plot([], [], ' ', label=f"Пересечения с X: {x_coords_str}") # Текст про X
287
- self.ax.plot([], [], ' ', label=f"Пересечения с Y: {y_coords_str}") # Текст про Y
286
+
288
287
 
289
288
 
290
289
  patches = self.ax.patches
@@ -313,18 +312,19 @@ class AdoptPlot():
313
312
 
314
313
 
315
314
  # Дальше твой код с точками и оформлением...
316
- try:
317
315
 
318
- try:
316
+ try:
317
+ if self.points:
318
+ try:
319
319
 
320
- for x in x_intercepts: self.ax.scatter(x, 0, s=60, color='red', marker='o', zorder=5)
321
- except:
322
- pass
323
- try:
320
+ for x in x_intercepts: self.ax.scatter(x, 0, s=60, color='red', marker='o', zorder=5, label=f"Пересечения с X: {x_coords_str}")
321
+ except:
322
+ pass
323
+ try:
324
324
 
325
- for y in y_intercepts: self.ax.scatter(0, y, s=60, color='blue', marker='o', zorder=5)
326
- except:
327
- pass
325
+ for y in y_intercepts: self.ax.scatter(0, y, s=60, color='blue', marker='o', zorder=5, label=f"Пересечения с Y: {y_coords_str}")
326
+ except:
327
+ pass
328
328
 
329
329
  self.ax.axhline(0, color='black', linewidth=1)
330
330
  self.ax.axvline(0, color='black', linewidth=1)
@@ -341,8 +341,10 @@ class AdoptPlot():
341
341
  logging.warning(f"Ошибка при добавлении оформления на p.ax: {e}")
342
342
 
343
343
  self.p.fig.tight_layout()
344
- if self.show:
344
+ self.plt = self.p.plt
345
+ if self.is_show:
345
346
  self.p.plt.show()
347
+
346
348
  return
347
349
  else:
348
350
  if isinstance(self.limit, (float, int)):
@@ -366,7 +368,7 @@ class AdoptPlot():
366
368
  self.fig, self.ax = plt.subplots()
367
369
  x_coords_str = ", ".join([f"({x:.2f}, 0)" for x in x_intercepts]) if x_intercepts else "Нет"
368
370
  y_coords_str = ", ".join([f"(0, {y:.2f})" for y in y_intercepts]) if y_intercepts else "Нет"
369
- self.ax.contour(X, Y, Z, levels=[0], colors='blue', linewidths=self.linewidth)
371
+ self.ax.contour(X, Y, Z, levels=[0], colors=self.color, linewidths=self.linewidth)
370
372
 
371
373
  self.ax.plot([], [], ' ', label=f"Уравнение: ${latex(self.eq)}$")
372
374
 
@@ -391,11 +393,20 @@ class AdoptPlot():
391
393
  self.ax.plot([], [], ' ', label=f"{self.text_legend}")
392
394
  if self.legend:
393
395
  self.ax.legend()
394
- plt.show()
396
+ self.plt = plt
397
+
398
+ if self.is_show:
399
+
400
+ self.plt.show()
395
401
 
396
402
  except Exception as e1:
397
403
  logging.warning(f"Matplotlib contour не сработал: {e1}")
398
404
  # Если контур упал (сингулярности), используем sympy.plot_implicit
399
405
  from sympy.plotting import plot_implicit
400
406
  p = plot_implicit(self.eq, (var1, -10, 10), (var2, -10, 10), show=False)
401
- p.show()
407
+ p.show()
408
+ def show(self):
409
+ try:
410
+ self.plt.show()
411
+ except:
412
+ raise PltNotFoundError("plt Not Found")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: adopt-plot
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: A universal plotter for implicit functions using adaptive engine selection.
5
5
  Author: VartRusData
6
6
  License: BSD 3-Clause
File without changes
File without changes
File without changes