# -*- coding: utf-8 -*-
"""
Created on Fri Oct  3 12:46:07 2025

@author: Moritz Romeike
"""

# ------------------------------------------------------------------------
# Programmcode 19_alternativ (Python): Heatmap der Lieferantenkonzentration
# ohne echarts
# ------------------------------------------------------------------------
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Marktanteile in Prozent
lieferanten_anteile = [
    12.5, 10.3, 9.8, 8.5, 7.6, 6.9, 6.5, 6.2, 5.8, 5.2,
    4.9, 4.6, 4.2, 3.9, 3.7, 3.5, 3.3, 3.1, 2.9, 2.7,
    2.5, 2.3, 2.1, 1.9, 1.8, 1.7, 1.6, 1.5, 1.4, 1.3,
    1.2, 1.1, 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3,
    0.3, 0.3, 0.3, 0.2, 0.2, 0.2, 0.1, 0.1, 0.1, 0.1
]

# DataFrame (wie in R)
df = pd.DataFrame({
    "Lieferant": [f"{i+1}" for i in range(len(lieferanten_anteile))],
    "Marktanteil": lieferanten_anteile
})

# Heatmap-Daten als 2D-Array (eine Zeile, alle Lieferanten nebeneinander)
heatmap_data = np.array([df["Marktanteil"].values])

# Plot
plt.figure(figsize=(14, 5))
im = plt.imshow(heatmap_data, cmap="RdYlGn_r", aspect="auto")

plt.xticks(range(len(df)), df["Lieferant"], rotation=90)
plt.yticks([])

plt.colorbar(im, label="Marktanteil (%)")
plt.title("Heatmap der Marktanteile der Lieferanten\nInntal AG")
plt.xlabel("Lieferant Nr.")
plt.tight_layout()
plt.show()
# ------------------------------------------------------------------------
