metodi/app/labs/lab2.py
2024-10-17 03:04:08 +03:00

41 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import numpy as np
import matplotlib.pyplot as plt
class lab2:
def __init__(self):
pass
def main(self):
# Данные для графика
x11 = np.random.normal(2, 1, [10, 1])
x21 = np.random.normal(6, 2, [10, 1])
print(x11,x21)
# Рисуем график
plt.scatter(x11, x21)
plt.xlabel("x")
plt.ylabel("y")
plt.title("Диаграмма рассеяния")
plt.show()
hist_data = np.vstack((x11, x21))
print ("Данные для гистограммы:", hist_data )
plt.hist(hist_data)
plt.xlabel('Значение признака')
plt.ylabel('Частота появления значения признака')
plt.title('Гистограмма')
plt.show()
# Коробочковая диаграмма
plt.boxplot((x11.ravel(), x21.ravel()), notch=True)
print("Данные для коробочковой диаграммы",x11.ravel(), x21.ravel())
plt.xlabel('№ объекта')
plt.ylabel('Значение признака')
plt.title('Ящик с усами')
plt.show()
if __name__ == "__main__":
l2 = lab2()
l2.main()