Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.8 kB
1
Indexable
Never
import matplotlib.pyplot as plt

# Сначала найдем топ клиентов
top_total = anomalies_grouped.nlargest(1, 'total_monthly_ton_dil')['client_inn_dil'].values[0]
top_MO = anomalies_grouped.nlargest(1, 'MO_dealer_monthly_ton_GZPN')['client_inn_dil'].values[0]
top_KP = anomalies_grouped.nlargest(1, 'KP_dealer_monthly_ton_GZPN')['client_inn_dil'].values[0]

# Создаем scatter plot
plt.figure(figsize=(10, 8))

# Все клиенты
plt.scatter(anomalies_grouped['total_monthly_ton_dil'], anomalies_grouped['MO_dealer_monthly_ton_GZPN'], color='gray', label='Остальные клиенты')

# Выделяем трех клиентов
plt.scatter(anomalies_grouped.loc[anomalies_grouped['client_inn_dil'] == top_total, 'total_monthly_ton_dil'],
            anomalies_grouped.loc[anomalies_grouped['client_inn_dil'] == top_total, 'MO_dealer_monthly_ton_GZPN'],
            color='red', label='Топ по total_monthly_ton_dil', edgecolor='black', s=100, zorder=5)

plt.scatter(anomalies_grouped.loc[anomalies_grouped['client_inn_dil'] == top_MO, 'total_monthly_ton_dil'],
            anomalies_grouped.loc[anomalies_grouped['client_inn_dil'] == top_MO, 'MO_dealer_monthly_ton_GZPN'],
            color='blue', label='Топ по MO_dealer_monthly_ton_GZPN', edgecolor='black', s=100, zorder=5)

plt.scatter(anomalies_grouped.loc[anomalies_grouped['client_inn_dil'] == top_KP, 'total_monthly_ton_dil'],
            anomalies_grouped.loc[anomalies_grouped['client_inn_dil'] == top_KP, 'MO_dealer_monthly_ton_GZPN'],
            color='green', label='Топ по KP_dealer_monthly_ton_GZPN', edgecolor='black', s=100, zorder=5)

plt.xlabel('Total Monthly Ton Dil')
plt.ylabel('MO Dealer Monthly Ton GZPN')
plt.title('Выделение Топ Клиентов на Scatter Plot')
plt.legend()
plt.show()
Leave a Comment