-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
76 lines (58 loc) · 2.52 KB
/
app.py
File metadata and controls
76 lines (58 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
from cycler import cycler
# Global Config
plt.rcParams['axes.prop_cycle'] = cycler(color=['#4E2A84', '#836EAA', '#B6ACD1', '#111111'])
# Set page configuration
st.set_page_config(
page_title="NFR-25 DAQ Interface",
page_icon="NFR",
layout="wide",
initial_sidebar_state="expanded"
)
# Sidebar
st.sidebar.title("Navigation")
st.sidebar.write("Use the sidebar to navigate the app.")
# File uploader in the sidebar
uploaded_file = st.sidebar.file_uploader("Upload your data file", type=["csv", "xlsx"])
# Main content
st.title("NFR 25 DAQ Interface")
st.write("Northwestern Formula Racing's DAQ data analysis tool. Upload your data using the sidebar, then select a graphing tool.")
if uploaded_file:
# Read the uploaded file
if uploaded_file.name.endswith(".csv"):
data = pd.read_csv(uploaded_file)
elif uploaded_file.name.endswith(".xlsx"):
data = pd.read_excel(uploaded_file)
if "Timestamp" in data.columns:
data["Timestamp"] = pd.to_datetime(data["Timestamp"])
st.write("File uploaded successfully!")
st.write("Preview of the data:")
st.dataframe(data)
# Basic plot selector
st.sidebar.title("Plotting Options")
plot_type = st.sidebar.selectbox("Select a plot type", ["Line Plot", "Scatter Plot"])
# Dynamically populate x-axis and y-axis options based on the uploaded file
x_axis = st.sidebar.selectbox("Select X-axis variable", data.columns)
y_axis = st.sidebar.selectbox("Select Y-axis variable", data.columns)
# Plot the graph based on user selection
if st.sidebar.button("Generate Plot"):
fig, ax = plt.subplots()
if plot_type == "Line Plot":
ax.plot(data[x_axis], data[y_axis], label=f"{y_axis} vs {x_axis}")
elif plot_type == "Scatter Plot":
ax.scatter(data[x_axis], data[y_axis], label=f"{y_axis} vs {x_axis}")
ax.set_xlabel(x_axis)
ax.set_ylabel(y_axis)
ax.set_title(f"{plot_type}: {y_axis} vs {x_axis}")
ax.legend()
st.pyplot(fig)
else:
st.write("Please upload a file to get started.")
# Add a map of Northwestern University with a pin on Ford Design Center
st.title("Welcome to Northwestern Formula Racing")
# Coordinates for Ford Design Center
ford_design_center_coords = [42.056459, -87.675267]
# Display the map
st.map(pd.DataFrame([{"lat": ford_design_center_coords[0], "lon": ford_design_center_coords[1]}]), color="#4E2A84", zoom=14)