Untitled

mail@pastecode.io avatar
unknown
python
7 months ago
1.1 kB
2
Indexable
Never
from matplotlib import pyplot as plt
import numpy as np

data = np.array([[53.5, 44.2, 55.9, 64.5, 64.4],
                 [48.2, 37.3, 35.2, 55.1, 64.5],
                 [63.4, 63.9, 58.3, 61.7, 66.1],
                 [63.5, 40.1, 57.4, 63.5, 64.5],
                 [66.1, 63.5, 64.9, 64.9, 65.2]])

x = np.linspace(0, 50, 5)
y = np.linspace(0, 50, 5)
X, Y = np.meshgrid(x, y)
plt.figure(figsize=(8, 6))

# origin='lower
plt.contourf(X, Y, data, cmap='turbo', levels=70, origin='lower')
plt.colorbar()

plt.xlabel('Расстояние между уколами по оси Х, мм', family='Times New Roman', fontsize=12)
plt.ylabel('Расстояние между уколами по оси Y, мм', family='Times New Roman', fontsize=12)
plt.title('Распределение твердости', family='Times New Roman', fontsize=12)

for i in range(data.shape[0]):
    for j in range(data.shape[1]):
        plt.scatter(x[i], y[j], c='black')
        plt.text(x[i], y[j], f'{data[i, j]}', color='white', ha='left', va='center', family='Times New Roman', fontsize=12)

plt.show()
Leave a Comment