ich habe mich mit matplotlib beschäftigt.
Nun habe ich mir eine Funktion zum Plotten von einem Dataframes geschrieben.
Code: Alles auswählen
def plote_single_index(df, index, wert="Close", label=""):
x_achse = []
y_achse = []
for eintrag in df[index]:
x_achse.append(eintrag["Datum"])
y_achse.append(eintrag[wert])
fig, ax = plt.subplots()
ax.plot(x_achse, y_achse)
ax.scatter(x_achse, y_achse, color="red", label=label)
ax.legend()
ax.set_title("Verlauf")
ax.set_xlabel("Tage")
ax.set_ylabel(wert)
fig.autofmt_xdate(rotation=45)
plt.show()
Mein anfänglicher Gedanke wäre, einer Funktion eine Liste mit Dictionaries zu übergeben. Die Dicts hätten folgenden Aufbau:
Code: Alles auswählen
[{"dataframe": [ ], "beschriftung": ""}, {"dataframe": [ ], "beschriftung": ""}]
Aufbau Dataframe:
Code: Alles auswählen
fuehler = {"fuehler1": [
{'Datum': pd.Timestamp('2021-03-12 00:00:00'), "Status": 1000},
{'Datum': pd.Timestamp('2021-03-13 00:00:00'), "Status": 1100},
{'Datum': pd.Timestamp('2021-03-14 00:00:00'), "Status": 1200},
{'Datum': pd.Timestamp('2021-03-15 00:00:00'), "Status": 1300},
{'Datum': pd.Timestamp('2021-03-16 00:00:00'), "Status": 1250},
{'Datum': pd.Timestamp('2021-03-31 00:00:00'), "Status": 1100}]}
durchschnitte = {"durchschnitt_fuehler1": [
{'Datum': pd.Timestamp('2021-03-12 00:00:00'), "Status": 900},
{'Datum': pd.Timestamp('2021-03-13 00:00:00'), "Status": 1100},
{'Datum': pd.Timestamp('2021-03-14 00:00:00'), "Status": 850},
{'Datum': pd.Timestamp('2021-03-15 00:00:00'), "Status": 1600},
{'Datum': pd.Timestamp('2021-03-16 00:00:00'), "Status": 1150},
{'Datum': pd.Timestamp('2021-03-31 00:00:00'), "Status": 1000}]}
LG