import matplotlib.pyplot as plt import seaborn as sns import numpy as np # Deine Daten (in mV) data_10g = [412, 284, 360, 548, 280, 304, 380, 312, 278, 444] data_20g = [960, 960, 992, 968, 936, 952, 1160, 1200, 1010, 1000] data_50g = [1180, 2020, 1120, 1260, 1240, 1580, 1140, 2340, 1700, 1060] data_100g = [4080, 5280, 5160, 5080, 3520, 4280, 4800, 5120, 4400, 4240] data = [data_10g, data_20g, data_50g, data_100g] labels = ['10g', '20g', '50g', '100g'] means = [np.mean(d) for d in data] stds = [np.std(d) for d in data] # Violin Plots mit Standardabweichung plt.figure(figsize=(8, 6)) ax = sns.violinplot(data=data, inner="box") # X-Achsen-Ticks und Beschriftungen anpassen x_coords = ax.get_xticks() new_labels = [] for i, label in enumerate(labels): new_labels.append(f"{label}\n⌀ {means[i]:.2f} mV\nσ {stds[i]:.2f}") ax.set_xticks(x_coords) ax.set_xticklabels(new_labels) ax.set_xlabel('Gewicht m [g]') ax.set_ylabel('Spannung U [mV]') #ax.set_title('Messwert Aufteilung der gemessenen Spannungen pro Gewicht') plt.tight_layout() plt.show()