Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import matplotlib as mpl | |
| def plot_filtered(df, time_column, data_column, t1, t2, scatter): | |
| filtered_df = df[(df[time_column] >= t1) & (df[time_column] <= t2)] | |
| fig, ax = plt.subplots(figsize=(8, 5)) | |
| mpl.rcParams['font.family'] = 'Arial' | |
| plt.yticks(fontname="Arial", fontsize=14, color="black") | |
| plt.xticks(fontname="Arial", fontsize=14, color = "black") | |
| plt.title(" ",fontname="Arial", fontsize=18, color="black", weight="bold", pad=10) | |
| gridwidth = 1.5 | |
| plt.grid(axis="y", linewidth=0.75, color="black") | |
| plt.grid(axis="x", linewidth=0.75, color="black") | |
| rand = ["top", "right", "bottom", "left"] | |
| for i in rand: | |
| plt.gca().spines[i].set_linewidth(gridwidth) | |
| ax.spines[i].set_color('black') | |
| if scatter: | |
| plt.scatter(filtered_df[time_column], filtered_df[data_column], color="#00509b", marker=".", s=15) | |
| else: | |
| plt.plot(filtered_df[time_column], filtered_df[data_column], color="#00509b", linewidth=2) | |
| plt.legend([data_column], fontsize=14) | |
| return fig | |
| def plot_filtered_mehrfach(df, time_column, data_column, data_column2, t1, t2): | |
| filtered_df = df[(df[time_column] >= t1) & (df[time_column] <= t2)] | |
| fig, ax = plt.subplots(figsize=(8, 5)) | |
| mpl.rcParams['font.family'] = 'Arial' | |
| plt.yticks(fontname="Arial", fontsize=14, color="black") | |
| plt.xticks(fontname="Arial", fontsize=14, color = "black") | |
| plt.title(" ",fontname="Arial", fontsize=18, color="black", weight="bold", pad=10) | |
| gridwidth = 1.5 | |
| plt.grid(axis="y", linewidth=0.75, color="black") | |
| plt.grid(axis="x", linewidth=0.75, color="black") | |
| rand = ["top", "right", "bottom", "left"] | |
| for i in rand: | |
| plt.gca().spines[i].set_linewidth(gridwidth) | |
| ax.spines[i].set_color('black') | |
| plt.plot(filtered_df[time_column], filtered_df[data_column], color="#00509b", linewidth=2) | |
| plt.plot(filtered_df[time_column], filtered_df[data_column2], color="red", linewidth=2) | |
| plt.legend([data_column, data_column2], fontsize=14) | |
| return fig | |
| def plot_data_matplotlib(df, time_column, data_column): | |
| fig, ax = plt.subplots(figsize=(8, 5)) | |
| mpl.rcParams['font.family'] = 'Arial' | |
| ax.set_xlabel(time_column, fontname="Arial", fontsize=16, labelpad=7) | |
| ax.set_ylabel(data_column, fontname="Arial", fontsize=16, labelpad=7) | |
| plt.yticks(fontname="Arial", fontsize=14, color="black") | |
| plt.xticks(fontname="Arial", fontsize=14, color = "black") | |
| plt.title(" ",fontname="Arial", fontsize=18, color="black", weight="bold", pad=10) | |
| gridwidth = 1.5 | |
| plt.grid(axis="y", linewidth=0.75, color="black") | |
| plt.grid(axis="x", linewidth=0.75, color="black") | |
| rand = ["top", "right", "bottom", "left"] | |
| for i in rand: | |
| plt.gca().spines[i].set_linewidth(gridwidth) | |
| ax.spines[i].set_color('black') | |
| plt.plot(df[time_column], df[data_column], color="#00509b", linewidth=2) | |
| return fig | |
| def plot_data_zeitfaktor(df, time_column, data_column, scatter): | |
| fig, ax = plt.subplots(figsize=(8, 5)) | |
| mpl.rcParams['font.family'] = 'Arial' | |
| ax.set_xlabel(time_column, fontname="Arial", fontsize=16, labelpad=7) | |
| ax.set_ylabel(data_column, fontname="Arial", fontsize=16, labelpad=7) | |
| plt.yticks(fontname="Arial", fontsize=14, color="black") | |
| plt.xticks(fontname="Arial", fontsize=14, color = "black") | |
| plt.title(" ",fontname="Arial", fontsize=18, color="black", weight="bold", pad=10) | |
| gridwidth = 1.5 | |
| plt.grid(axis="y", linewidth=0.75, color="black") | |
| plt.grid(axis="x", linewidth=0.75, color="black") | |
| rand = ["top", "right", "bottom", "left"] | |
| for i in rand: | |
| plt.gca().spines[i].set_linewidth(gridwidth) | |
| ax.spines[i].set_color('black') | |
| if scatter: | |
| plt.scatter(df[time_column], df[data_column], color="#00509b", marker=".", s=5) | |
| else: | |
| plt.plot(df[time_column], df[data_column], color="#00509b", linewidth=2) | |
| return fig | |