The package will help MIPT students to draw graphs easier
Project description
Длинное описание, которое когда-то появится
Для установки:
pip install -i https://test.pypi.org/simple/ miptlabs
Чтобы нарисовать что-то:
from miptlabs.plotter import pretty_plot, show
from numpy import linspace
# точки для построения графика
x = linspace(0, 5, 20)
y = x * x
pretty_plot(x, y)
show()
Точки можно просто соединить написав line=True:
pretty_plot(x, y, line=True, legend='$y = x^2$')
Так как для данный с лаб простое соединение вряд ли подойдет, то в пакете есть разные апроксиматоры Для примера можно взять зависимость координаты от рвемени при равноускоренном движении
from src.miptlabs.plotter import pretty_plot, show
from src.miptlabs.approximators import Polynomial
from numpy import linspace
import numpy as np
# точки для построения графика
x = linspace(0, 5, 20)
y = x * x + np.random.normal(size=x.shape)
ax = pretty_plot(x, y, legend='$x = t^2$ + random')
# Апроксимация
approximator = Polynomial(deg=2)
appr_x, appr_y = approximator.approximate(x, y)
# Вывод формулы для латеха
print(approximator.label('t', 'x'))
# >>> $y = 1.03t^{2}-0.205t+0.158$
№ Построение графика. Параметры говорят сами за себя
pretty_plot(appr_x, appr_y, axes=ax, points=False, line=True,
legend=approximator.label('t', 'x'), xlabel='t, сек', ylabel='x, м', title='График $x(t)$')
ax.figure.savefig('examples/approx.png')
show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
miptlabs-1.0.5.tar.gz
(12.3 kB
view hashes)
Built Distribution
miptlabs-1.0.5-py3-none-any.whl
(13.6 kB
view hashes)