adopt-plot 0.0.1__tar.gz → 0.0.2__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.
- {adopt_plot-0.0.1/src/adopt_plot.egg-info → adopt_plot-0.0.2}/PKG-INFO +1 -1
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/pyproject.toml +1 -1
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/src/adopt_plot/__init__.py +2 -0
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/src/adopt_plot/plot.py +30 -19
- {adopt_plot-0.0.1 → adopt_plot-0.0.2/src/adopt_plot.egg-info}/PKG-INFO +1 -1
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/LICENSE +0 -0
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/README.md +0 -0
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/setup.cfg +0 -0
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/src/adopt_plot.egg-info/SOURCES.txt +0 -0
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/src/adopt_plot.egg-info/dependency_links.txt +0 -0
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/src/adopt_plot.egg-info/requires.txt +0 -0
- {adopt_plot-0.0.1 → adopt_plot-0.0.2}/src/adopt_plot.egg-info/top_level.txt +0 -0
|
@@ -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 .__init__ 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.
|
|
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
|
-
|
|
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
|
-
|
|
316
|
+
try:
|
|
317
|
+
if self.points:
|
|
318
|
+
try:
|
|
319
319
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
-
|
|
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=
|
|
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
|
|
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")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|