Engee documentation
Notebook

How to use Python in Engee

In this example, we will look at the principles of interacting with Python from the Engee environment, using the .ipynb file format, and conduct several exercises with graphs.

Getting started

Importing computing (NumPy) and graphics (matplotlib) libraries:

In [ ]:
import matplotlib.pyplot as plt # Пакет построения графиков
import numpy as np # Фундаментальный пакет для научных вычислений

Plotting graphs

Plotting graphs by points:

In [ ]:
plt.plot([1, 2], [3, 4]) # Отрисовка возрастающего графика
plt.show() # Отображение всех ранее описанных графиков
plt.plot([1, 2], [4, 3]) # Отрисовка убывающего графика
plt.show()
No description has been provided for this image
No description has been provided for this image
image.png image_2.png

Building multiple graphs

Declaring a function for plotting graphs.

In [ ]:
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t) # Математическая формула

Declaring arrays.

In [ ]:
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)

Plotting graphs.

In [ ]:
plt.figure() # Объявление фигуры (Пространства для отрисовки графика)
plt.subplot(211) # Объявление первого из двух окон графика
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k') 
plt.subplot(212) 
plt.plot(t2, np.cos(2*np.pi*t2), 'r--') 
plt.show() 
No description has been provided for this image
image.png

Plotting graphs with keywords

Declaring a dictionary list.

In [ ]:
data = {'a': np.arange(50), # Возвращает равномерно распределенные значения в пределах заданного интервала.
        'c': np.random.randint(0, 50, 50), # Возвращает случайное целое в заданных пределах.
        'd': np.random.randn(50)} # Возврат выборки (или выборок) из «стандартного нормального» распределения.
data['b'] = data['a'] + 10 * np.random.randn(50) # Расчёт b
data['d'] = np.abs(data['d']) * 100 # d взятый по модулю и умноженный на 100

Point drawing of the graph and the signature of the axes.

In [ ]:
plt.scatter('a', 'b', c='c', s='d', data=data) # Точечная диаграмма зависимости y от x с разным размером маркера и/или цветом.
plt.xlabel('entry a') # Подписать ось X
plt.ylabel('entry b') # Подписать ось Y
plt.show()
No description has been provided for this image
image.png

Plotting graphs for categorical data

Declaring arrays of data and an array of category names.

In [ ]:
names = ['group_a', 'group_b', 'group_c'] # Массив строк
values = [1, 10, 100] # Массив чисел
In [ ]:
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.bar(names, values) 
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values) 
plt.suptitle('Categorical Plotting')  # Объявления заголовка графика
plt.show()
No description has been provided for this image
image.png

Conclusion

In this example, we demonstrated the capabilities of Engee in writing and implementing algorithms in Python. In the modern world, this feature is relevant due to the volume of functionality implemented in Python and its popularity.