Spaces:
Runtime error
Runtime error
bug fix
Browse files
app.py
CHANGED
@@ -148,27 +148,29 @@ def main():
|
|
148 |
preds = predict(model, dataloader, st.session_state.date)
|
149 |
update_plot(df, preds, axs, fig)
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
ax.legend()
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
x_initial = np.linspace(0, 2*np.pi, 100)
|
161 |
-
y_initial = np.cos(x_initial)
|
162 |
-
ax.plot(x_initial, y_initial, label='Initial Line')
|
163 |
-
ax.set_xlabel('X-axis')
|
164 |
-
ax.set_ylabel('Y-axis')
|
165 |
-
ax.set_title('Plot')
|
166 |
-
ax.legend()
|
167 |
-
st.pyplot(figs)
|
168 |
|
169 |
-
# Button to update the plot
|
170 |
if st.button('Add Line'):
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
|
174 |
|
|
|
148 |
preds = predict(model, dataloader, st.session_state.date)
|
149 |
update_plot(df, preds, axs, fig)
|
150 |
|
151 |
+
|
152 |
+
@st.cache(allow_output_mutation=True)
|
153 |
+
def create_plot():
|
154 |
+
fig, ax = plt.subplots()
|
155 |
+
x_initial = np.linspace(0, 2*np.pi, 100)
|
156 |
+
y_initial = np.cos(x_initial)
|
157 |
+
ax.plot(x_initial, y_initial, label='Initial Line')
|
158 |
+
ax.set_xlabel('X-axis')
|
159 |
+
ax.set_ylabel('Y-axis')
|
160 |
+
ax.set_title('Plot')
|
161 |
ax.legend()
|
162 |
+
return fig
|
163 |
+
|
164 |
+
fig = create_plot()
|
165 |
+
st.pyplot(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
|
|
167 |
if st.button('Add Line'):
|
168 |
+
ax = fig.axes[0]
|
169 |
+
x_new = np.linspace(0, 2*np.pi, 100)
|
170 |
+
y_new = np.sin(x_new)
|
171 |
+
ax.plot(x_new, y_new, label='New Line')
|
172 |
+
ax.legend()
|
173 |
+
st.pyplot(fig)
|
174 |
|
175 |
|
176 |
|