adopt-plot 0.0.2__tar.gz → 0.0.4__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.4/PKG-INFO +80 -0
- adopt_plot-0.0.4/README.md +65 -0
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/pyproject.toml +1 -1
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/src/adopt_plot/plot.py +4 -2
- adopt_plot-0.0.4/src/adopt_plot.egg-info/PKG-INFO +80 -0
- adopt_plot-0.0.2/PKG-INFO +0 -19
- adopt_plot-0.0.2/README.md +0 -4
- adopt_plot-0.0.2/src/adopt_plot.egg-info/PKG-INFO +0 -19
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/LICENSE +0 -0
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/setup.cfg +0 -0
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/src/adopt_plot/__init__.py +0 -0
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/src/adopt_plot.egg-info/SOURCES.txt +0 -0
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/src/adopt_plot.egg-info/dependency_links.txt +0 -0
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/src/adopt_plot.egg-info/requires.txt +0 -0
- {adopt_plot-0.0.2 → adopt_plot-0.0.4}/src/adopt_plot.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adopt-plot
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: A universal plotter for implicit functions using adaptive engine selection.
|
|
5
|
+
Author: VartRusData
|
|
6
|
+
License: BSD 3-Clause
|
|
7
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: sympy
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# adopt-plot
|
|
17
|
+
|
|
18
|
+
A library for plotting implicit functions using two rendering engines:
|
|
19
|
+
|
|
20
|
+
- `contour` from `matplotlib`.
|
|
21
|
+
- `plot_implicit` which internally uses **Adaptive Marching Squares (AMR)** — an adaptive algorithm that correctly handles the domain of definition and discontinuities.
|
|
22
|
+
|
|
23
|
+
**Automatic selection:** If the equation has domain restrictions (e.g., logarithm or square root), `plot_implicit` is used. If the function is smooth, the fast `contour` engine is chosen. Visually, they are indistinguishable, but the best algorithm is selected automatically.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install adopt-plot
|
|
31
|
+
```
|
|
32
|
+
## Quick Start
|
|
33
|
+
Plot a graph in one line:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from adopt_plot import AdoptPlot
|
|
37
|
+
|
|
38
|
+
# The plot will open immediately
|
|
39
|
+
plot = AdoptPlot("y = 2*x + 2")
|
|
40
|
+
```
|
|
41
|
+
Or with deferred display (to add custom elements first):
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from adopt_plot import AdoptPlot
|
|
45
|
+
|
|
46
|
+
plot = AdoptPlot("y = 1/x", show=False)
|
|
47
|
+
# Add custom elements here:
|
|
48
|
+
plot.ax.scatter(2, 2, color='red')
|
|
49
|
+
plot.show()
|
|
50
|
+
# Show the plot after modifications
|
|
51
|
+
```
|
|
52
|
+
All plot elements (`axes`, `fig`, `plt`) are accessible via the plot object and its attributes:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from adopt_plot import AdoptPlot
|
|
56
|
+
plot = AdoptPlot("y = 1/x", show=False)
|
|
57
|
+
plot.ax.set_xlim(-10, 10) # Change X-axis limits
|
|
58
|
+
plot.fig.savefig("my_plot.png", dpi=300)# Save to file
|
|
59
|
+
```
|
|
60
|
+
## Parameters
|
|
61
|
+
|
|
62
|
+
When creating an `AdoptPlot` object, the following parameters are available:
|
|
63
|
+
|
|
64
|
+
- **`expr`** (`str`): The equation string (e.g., `"y = 1/x"`).
|
|
65
|
+
- **`lib`** (`Literal['contour', 'implicit', None]`): Forced rendering engine. Default is `None` (automatic selection).
|
|
66
|
+
- **`xlims`, `ylims`** (`Tuple[float, float]`): Initial visible range for the plot. Default `(-20, 20)`.
|
|
67
|
+
- **`n`** (`int`): Grid density for the `contour` engine. Default `10000`.
|
|
68
|
+
- **`depth`** (`int`): Adaptive refinement depth for `plot_implicit`. Default `9`.
|
|
69
|
+
- **`linewidth`** (`float`): Thickness of the plot line. Default `2.0`.
|
|
70
|
+
- **`limit`** (`float | Tuple[float, float, float, float]`): Computational domain. Pass a single number (square) or a tuple of 4 numbers `(x_min, x_max, y_min, y_max)`. Default `100`.
|
|
71
|
+
- **`color`** (`str`): Line color. Default `'blue'`.
|
|
72
|
+
- **`legend`** (`bool`): Whether to display the legend. Default `True`.
|
|
73
|
+
- **`points`** (`bool`): Whether to display axis intersection points. Default `True`.
|
|
74
|
+
- **`grid`** (`bool`): Whether to display the grid. Default `True`.
|
|
75
|
+
- **`interact`** (`bool`): Allow zooming and panning via keyboard (`Ctrl +` and `Ctrl -`). Default `True`.
|
|
76
|
+
- **`show`** (`bool`): If `False`, the plot does not open immediately, allowing you to add elements. Default `True`.
|
|
77
|
+
- **`text_legend`** (`str`): Additional text for the legend. Default `None`.
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
Distributed under the **BSD 3-Clause** license.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# adopt-plot
|
|
2
|
+
|
|
3
|
+
A library for plotting implicit functions using two rendering engines:
|
|
4
|
+
|
|
5
|
+
- `contour` from `matplotlib`.
|
|
6
|
+
- `plot_implicit` which internally uses **Adaptive Marching Squares (AMR)** — an adaptive algorithm that correctly handles the domain of definition and discontinuities.
|
|
7
|
+
|
|
8
|
+
**Automatic selection:** If the equation has domain restrictions (e.g., logarithm or square root), `plot_implicit` is used. If the function is smooth, the fast `contour` engine is chosen. Visually, they are indistinguishable, but the best algorithm is selected automatically.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install adopt-plot
|
|
16
|
+
```
|
|
17
|
+
## Quick Start
|
|
18
|
+
Plot a graph in one line:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from adopt_plot import AdoptPlot
|
|
22
|
+
|
|
23
|
+
# The plot will open immediately
|
|
24
|
+
plot = AdoptPlot("y = 2*x + 2")
|
|
25
|
+
```
|
|
26
|
+
Or with deferred display (to add custom elements first):
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from adopt_plot import AdoptPlot
|
|
30
|
+
|
|
31
|
+
plot = AdoptPlot("y = 1/x", show=False)
|
|
32
|
+
# Add custom elements here:
|
|
33
|
+
plot.ax.scatter(2, 2, color='red')
|
|
34
|
+
plot.show()
|
|
35
|
+
# Show the plot after modifications
|
|
36
|
+
```
|
|
37
|
+
All plot elements (`axes`, `fig`, `plt`) are accessible via the plot object and its attributes:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from adopt_plot import AdoptPlot
|
|
41
|
+
plot = AdoptPlot("y = 1/x", show=False)
|
|
42
|
+
plot.ax.set_xlim(-10, 10) # Change X-axis limits
|
|
43
|
+
plot.fig.savefig("my_plot.png", dpi=300)# Save to file
|
|
44
|
+
```
|
|
45
|
+
## Parameters
|
|
46
|
+
|
|
47
|
+
When creating an `AdoptPlot` object, the following parameters are available:
|
|
48
|
+
|
|
49
|
+
- **`expr`** (`str`): The equation string (e.g., `"y = 1/x"`).
|
|
50
|
+
- **`lib`** (`Literal['contour', 'implicit', None]`): Forced rendering engine. Default is `None` (automatic selection).
|
|
51
|
+
- **`xlims`, `ylims`** (`Tuple[float, float]`): Initial visible range for the plot. Default `(-20, 20)`.
|
|
52
|
+
- **`n`** (`int`): Grid density for the `contour` engine. Default `10000`.
|
|
53
|
+
- **`depth`** (`int`): Adaptive refinement depth for `plot_implicit`. Default `9`.
|
|
54
|
+
- **`linewidth`** (`float`): Thickness of the plot line. Default `2.0`.
|
|
55
|
+
- **`limit`** (`float | Tuple[float, float, float, float]`): Computational domain. Pass a single number (square) or a tuple of 4 numbers `(x_min, x_max, y_min, y_max)`. Default `100`.
|
|
56
|
+
- **`color`** (`str`): Line color. Default `'blue'`.
|
|
57
|
+
- **`legend`** (`bool`): Whether to display the legend. Default `True`.
|
|
58
|
+
- **`points`** (`bool`): Whether to display axis intersection points. Default `True`.
|
|
59
|
+
- **`grid`** (`bool`): Whether to display the grid. Default `True`.
|
|
60
|
+
- **`interact`** (`bool`): Allow zooming and panning via keyboard (`Ctrl +` and `Ctrl -`). Default `True`.
|
|
61
|
+
- **`show`** (`bool`): If `False`, the plot does not open immediately, allowing you to add elements. Default `True`.
|
|
62
|
+
- **`text_legend`** (`str`): Additional text for the legend. Default `None`.
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
Distributed under the **BSD 3-Clause** license.
|
|
@@ -9,7 +9,7 @@ import re
|
|
|
9
9
|
import sympy
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
from .
|
|
12
|
+
from . import TooManyVariablesError, PltNotFoundError
|
|
13
13
|
|
|
14
14
|
def get_all_sympy_function_names():
|
|
15
15
|
"""Собирает имена всех встроенных функций и констант SymPy."""
|
|
@@ -260,7 +260,7 @@ class AdoptPlot():
|
|
|
260
260
|
# Принудительно перерисовываем график
|
|
261
261
|
event.canvas.draw_idle()
|
|
262
262
|
# === 2. Увеличиваем разрешение для гладкости (было 500, стало 1000) ===
|
|
263
|
-
if self.lib == 'implicit' or (has_odz and self.lib is None):
|
|
263
|
+
if self.lib == 'implicit' or (has_odz(expr, var1) and self.lib is None):
|
|
264
264
|
from sympy.plotting import plot_implicit
|
|
265
265
|
if isinstance(self.limit, (int, float)):
|
|
266
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)
|
|
@@ -366,6 +366,8 @@ class AdoptPlot():
|
|
|
366
366
|
Z = f(X, Y)
|
|
367
367
|
# print(Z)
|
|
368
368
|
self.fig, self.ax = plt.subplots()
|
|
369
|
+
if self.interact:
|
|
370
|
+
self.fig.canvas.mpl_connect('key_press_event', zoom_key_handler)
|
|
369
371
|
x_coords_str = ", ".join([f"({x:.2f}, 0)" for x in x_intercepts]) if x_intercepts else "Нет"
|
|
370
372
|
y_coords_str = ", ".join([f"(0, {y:.2f})" for y in y_intercepts]) if y_intercepts else "Нет"
|
|
371
373
|
self.ax.contour(X, Y, Z, levels=[0], colors=self.color, linewidths=self.linewidth)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adopt-plot
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: A universal plotter for implicit functions using adaptive engine selection.
|
|
5
|
+
Author: VartRusData
|
|
6
|
+
License: BSD 3-Clause
|
|
7
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: sympy
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# adopt-plot
|
|
17
|
+
|
|
18
|
+
A library for plotting implicit functions using two rendering engines:
|
|
19
|
+
|
|
20
|
+
- `contour` from `matplotlib`.
|
|
21
|
+
- `plot_implicit` which internally uses **Adaptive Marching Squares (AMR)** — an adaptive algorithm that correctly handles the domain of definition and discontinuities.
|
|
22
|
+
|
|
23
|
+
**Automatic selection:** If the equation has domain restrictions (e.g., logarithm or square root), `plot_implicit` is used. If the function is smooth, the fast `contour` engine is chosen. Visually, they are indistinguishable, but the best algorithm is selected automatically.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install adopt-plot
|
|
31
|
+
```
|
|
32
|
+
## Quick Start
|
|
33
|
+
Plot a graph in one line:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from adopt_plot import AdoptPlot
|
|
37
|
+
|
|
38
|
+
# The plot will open immediately
|
|
39
|
+
plot = AdoptPlot("y = 2*x + 2")
|
|
40
|
+
```
|
|
41
|
+
Or with deferred display (to add custom elements first):
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from adopt_plot import AdoptPlot
|
|
45
|
+
|
|
46
|
+
plot = AdoptPlot("y = 1/x", show=False)
|
|
47
|
+
# Add custom elements here:
|
|
48
|
+
plot.ax.scatter(2, 2, color='red')
|
|
49
|
+
plot.show()
|
|
50
|
+
# Show the plot after modifications
|
|
51
|
+
```
|
|
52
|
+
All plot elements (`axes`, `fig`, `plt`) are accessible via the plot object and its attributes:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from adopt_plot import AdoptPlot
|
|
56
|
+
plot = AdoptPlot("y = 1/x", show=False)
|
|
57
|
+
plot.ax.set_xlim(-10, 10) # Change X-axis limits
|
|
58
|
+
plot.fig.savefig("my_plot.png", dpi=300)# Save to file
|
|
59
|
+
```
|
|
60
|
+
## Parameters
|
|
61
|
+
|
|
62
|
+
When creating an `AdoptPlot` object, the following parameters are available:
|
|
63
|
+
|
|
64
|
+
- **`expr`** (`str`): The equation string (e.g., `"y = 1/x"`).
|
|
65
|
+
- **`lib`** (`Literal['contour', 'implicit', None]`): Forced rendering engine. Default is `None` (automatic selection).
|
|
66
|
+
- **`xlims`, `ylims`** (`Tuple[float, float]`): Initial visible range for the plot. Default `(-20, 20)`.
|
|
67
|
+
- **`n`** (`int`): Grid density for the `contour` engine. Default `10000`.
|
|
68
|
+
- **`depth`** (`int`): Adaptive refinement depth for `plot_implicit`. Default `9`.
|
|
69
|
+
- **`linewidth`** (`float`): Thickness of the plot line. Default `2.0`.
|
|
70
|
+
- **`limit`** (`float | Tuple[float, float, float, float]`): Computational domain. Pass a single number (square) or a tuple of 4 numbers `(x_min, x_max, y_min, y_max)`. Default `100`.
|
|
71
|
+
- **`color`** (`str`): Line color. Default `'blue'`.
|
|
72
|
+
- **`legend`** (`bool`): Whether to display the legend. Default `True`.
|
|
73
|
+
- **`points`** (`bool`): Whether to display axis intersection points. Default `True`.
|
|
74
|
+
- **`grid`** (`bool`): Whether to display the grid. Default `True`.
|
|
75
|
+
- **`interact`** (`bool`): Allow zooming and panning via keyboard (`Ctrl +` and `Ctrl -`). Default `True`.
|
|
76
|
+
- **`show`** (`bool`): If `False`, the plot does not open immediately, allowing you to add elements. Default `True`.
|
|
77
|
+
- **`text_legend`** (`str`): Additional text for the legend. Default `None`.
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
Distributed under the **BSD 3-Clause** license.
|
adopt_plot-0.0.2/PKG-INFO
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: adopt-plot
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: A universal plotter for implicit functions using adaptive engine selection.
|
|
5
|
-
Author: VartRusData
|
|
6
|
-
License: BSD 3-Clause
|
|
7
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
8
|
-
Requires-Python: >=3.9
|
|
9
|
-
Description-Content-Type: text/markdown
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
Requires-Dist: sympy
|
|
12
|
-
Requires-Dist: matplotlib
|
|
13
|
-
Requires-Dist: numpy
|
|
14
|
-
Dynamic: license-file
|
|
15
|
-
|
|
16
|
-
# adopt-plot
|
|
17
|
-
|
|
18
|
-
A simple Python library for plotting implicit functions with adaptive engine selection.
|
|
19
|
-
Just pass an equation and get a beautiful, mathematically correct plot.
|
adopt_plot-0.0.2/README.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: adopt-plot
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: A universal plotter for implicit functions using adaptive engine selection.
|
|
5
|
-
Author: VartRusData
|
|
6
|
-
License: BSD 3-Clause
|
|
7
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
8
|
-
Requires-Python: >=3.9
|
|
9
|
-
Description-Content-Type: text/markdown
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
Requires-Dist: sympy
|
|
12
|
-
Requires-Dist: matplotlib
|
|
13
|
-
Requires-Dist: numpy
|
|
14
|
-
Dynamic: license-file
|
|
15
|
-
|
|
16
|
-
# adopt-plot
|
|
17
|
-
|
|
18
|
-
A simple Python library for plotting implicit functions with adaptive engine selection.
|
|
19
|
-
Just pass an equation and get a beautiful, mathematically correct plot.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|