1
1
import numpy as np
2
2
import sympy
3
- # import matplotlib.pyplot as plt
4
3
5
4
from graph .mpl_canvas import MlpCanvas
6
5
from service import only_one_true
6
+ from settings import Settings
7
7
8
8
9
9
class CanvasSliceGraph (MlpCanvas ):
10
10
"""Класс для построения графиков срезов функции"""
11
- def create_graph (self , constraints_high , constraints_down , func , expression = "" , axes = 0 , h = 0.2 , amp_noise = 0 ): # self, constraints_x, constraints_y, func, expr_x="", expr_y="", expression="", axes=0, h=0.2, amp_noise=0
11
+ def create_graph (self , constraints_high , constraints_down , func , expression = "" , axes = 0 , h = 0.2 , amp_noise = 0 ):
12
12
# TODO: добавить подпись для легенды
13
13
np .random .seed ()
14
14
@@ -20,11 +20,10 @@ def create_graph(self, constraints_high, constraints_down, func, expression="",
20
20
axes = axes ,
21
21
h = h ,
22
22
amp_noise = amp_noise )
23
- self .axes .plot (x , y , lw = 1 , label = 'F' )
24
- # plt.legend(loc='center left', title=legend_title, bbox_to_anchor=(1, 0.5))
23
+ self .axes .plot (x , y , lw = Settings .settings ['line_thickness' ].value , label = 'F' )
25
24
self .axes .grid ()
26
25
27
- def make_data (self , constraints_high , constraints_down , func , expression = "" , axes = 0 , h = 0.2 , amp_noise = 0 ): # expression_x="", expression_y="",
26
+ def make_data (self , constraints_high , constraints_down , func , expression = "" , axes = 0 , h = 0.2 , amp_noise = 0 ):
28
27
# TODO: сделать в параметрах одно выражение expression и номер оси для среза
29
28
"""
30
29
Метод генерации данных для построения графика
@@ -44,44 +43,6 @@ def make_data(self, constraints_high, constraints_down, func, expression="", axe
44
43
:return: возвращает массив координат x(x1) или y(x2) и координаты функции z, одномерные массивы
45
44
"""
46
45
# TODO: параметрические уравнения?
47
- # if expression_x != "":
48
- # # x1
49
- # y = np.arange(constraints_y[0], constraints_y[1], h)
50
- # z = np.zeros(len(y))
51
- # if expression_x.find('y') != -1:
52
- # var_y = sympy.Symbol('y')
53
- # expr = sympy.S(expression_x)
54
- # f = sympy.lambdify(var_y, expr, "numpy")
55
- # x = f(y)
56
- # # for i in range(len(y)):
57
- # # z[i] = func([x[i], y[i]])
58
- # else:
59
- # x = float(expression_x)
60
- # for i in range(len(y)):
61
- # z[i] = func([x, y[i]])
62
- # if amp_noise > 0:
63
- # z[i] = z[i] + np.random.uniform(-amp_noise, amp_noise)
64
- # return y, z
65
- #
66
- # if expression_y != "":
67
- # # x2
68
- # x = np.arange(constraints_x[0], constraints_x[1], h)
69
- # z = np.zeros(len(x))
70
- # if expression_y.find('x') != -1:
71
- # var_x = sympy.Symbol('x')
72
- # expr = sympy.S(expression_y)
73
- # f = sympy.lambdify(var_x, expr, "numpy")
74
- # y = f(x)
75
- # # for i in range(len(x)):
76
- # # z[i] = func([x[i], y[i]])
77
- # else:
78
- # y = float(expression_y)
79
- # for i in range(len(x)):
80
- # z[i] = func([x[i], y])
81
- # if amp_noise > 0:
82
- # z[i] = z[i] + np.random.uniform(-amp_noise, amp_noise)
83
- #
84
- # return x, z
85
46
86
47
symbol = ["x2" , "x1" ]
87
48
if (expression != "" ) and (0 <= axes < 2 ):
0 commit comments