Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
import matplotlib.pyplot as plt
|
4 |
|
5 |
# Load data
|
@@ -43,16 +44,17 @@ db_p['date']= pd.to_datetime(db_p['date'])
|
|
43 |
db['date'] = db['date'].dt.strftime('%Y-%m-%d')
|
44 |
db_p['date'] = db_p['date'].dt.strftime('%Y-%m-%d')
|
45 |
|
46 |
-
def plot_graph(x,y,xp,yp):
|
47 |
st.write("### กราฟเส้น Time Series")
|
48 |
plt.figure(figsize=(10, 6))
|
|
|
49 |
color = 'yellow' if selected_data == 'Electricity' else 'green' if selected_data == 'LPG' else 'red'
|
50 |
-
|
51 |
-
|
52 |
plt.xlabel("Date")
|
53 |
plt.ylabel("Value")
|
54 |
plt.title("Time Series")
|
55 |
plt.legend()
|
56 |
return st.pyplot(plt)
|
57 |
|
58 |
-
plot_graph(db['date'],db['Y'],db_p['date'],db_p['predict'])
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import seaborn as sns
|
4 |
import matplotlib.pyplot as plt
|
5 |
|
6 |
# Load data
|
|
|
44 |
db['date'] = db['date'].dt.strftime('%Y-%m-%d')
|
45 |
db_p['date'] = db_p['date'].dt.strftime('%Y-%m-%d')
|
46 |
|
47 |
+
def plot_graph(x, y, xp, yp):
|
48 |
st.write("### กราฟเส้น Time Series")
|
49 |
plt.figure(figsize=(10, 6))
|
50 |
+
sns.set(style="whitegrid") # ตั้งค่าสไตล์กราฟของ Seaborn
|
51 |
color = 'yellow' if selected_data == 'Electricity' else 'green' if selected_data == 'LPG' else 'red'
|
52 |
+
sns.lineplot(x=x, y=y, label="Actual", color=color) # ใช้ sns.lineplot() แทน plt.plot() เพื่อสร้างกราฟเส้น
|
53 |
+
sns.lineplot(x=xp, y=yp, label="Predict", color="blue")
|
54 |
plt.xlabel("Date")
|
55 |
plt.ylabel("Value")
|
56 |
plt.title("Time Series")
|
57 |
plt.legend()
|
58 |
return st.pyplot(plt)
|
59 |
|
60 |
+
plot_graph(db['date'], db['Y'], db_p['date'], db_p['predict'])
|