48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
import numpy as np
|
||
import matplotlib.pyplot as plt
|
||
|
||
class GraphStatic:
|
||
@classmethod
|
||
def plot(cls, xs: np.ndarray, ys: np.ndarray, params: dict[str, str]) -> plt.Figure:
|
||
"""
|
||
строим график через
|
||
"""
|
||
ax, fig = plt.subplots(...)
|
||
|
||
""""
|
||
Все методы при этом статичные
|
||
"""
|
||
|
||
cls.__some_func(1, 2)
|
||
|
||
"""
|
||
И возвращаем Figure
|
||
"""
|
||
|
||
return fig
|
||
|
||
@staticmethod
|
||
def __some_func(arg1, agr2):
|
||
...
|
||
|
||
|
||
class GraphStatefull:
|
||
def __init__(self, xs: np.ndarray, ys: np.ndarray, params: dict[str, str]):
|
||
self.__xs = xs
|
||
self.__ys = ys
|
||
|
||
self.__params = params
|
||
ax, fig = plt.subplots(...)
|
||
|
||
self.__fig = fig
|
||
self.__ax = ax
|
||
|
||
"""
|
||
строим график
|
||
"""
|
||
|
||
def __some_func(self, arg1, arg2):
|
||
self.__ax.do_something(self.__params['something'])
|
||
|
||
def get_fig(self) -> plt.Figure:
|
||
return self.__fig |