# -*- coding: utf-8 -*-
"""
Created on Fri Oct  3 12:29:09 2025

@author: Moritz Romeike
"""

# ------------------------------------------------------------------------
# Programmcode 10 (Python): Boxplot für die Diodenproduktion insgesamt
# ------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

def boxplot_dioden(produktion):
    fig, ax = plt.subplots()
    bp = ax.boxplot(produktion,
                    patch_artist=True,   # ermöglicht Farbfüllung
                    notch=False,         # Konfidenzintervall für Median (hier deaktiviert)
                    vert=True)           # vertikale Orientierung
    
    # Farbe einstellen
    for patch in bp['boxes']:
        patch.set_facecolor("lightblue")
    
    ax.set_title("Boxplot der produzierten Power-Dioden")
    ax.set_ylabel("Anzahl produzierter Dioden")
    ax.set_xlabel("Produktion")
    
    # Median berechnen und als Text oberhalb einfügen
    median_wert = np.median(produktion)
    ax.text(1.05, median_wert, f"Median: {int(median_wert)}",
            verticalalignment="center", color="red", fontsize=9)
    
    plt.tight_layout()
    plt.show()

# Beispiel-Datensatz für die Diodenproduktion der Inntal AG (Dioden 01 bis 08)
dioden_produktion = [50000, 42000, 39000, 37000, 35000, 31000, 29000, 25000]

# Aufruf der Funktion
boxplot_dioden(dioden_produktion)
# ------------------------------------------------------------------------
