Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,16 +61,6 @@ crash_periods = {
|
|
| 61 |
'2020-02-01': '2020-04-01'
|
| 62 |
}
|
| 63 |
|
| 64 |
-
# CSS for better full-screen responsiveness
|
| 65 |
-
hide_streamlit_style = """
|
| 66 |
-
<style>
|
| 67 |
-
iframe[width="100%"] {
|
| 68 |
-
height: 100vh !important;
|
| 69 |
-
}
|
| 70 |
-
</style>
|
| 71 |
-
"""
|
| 72 |
-
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
| 73 |
-
|
| 74 |
# Run button
|
| 75 |
if st.sidebar.button('Run Analysis'):
|
| 76 |
# Fetch the data from FRED
|
|
@@ -160,16 +150,14 @@ if st.sidebar.button('Run Analysis'):
|
|
| 160 |
traceorder='normal',
|
| 161 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 162 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 163 |
-
)
|
| 164 |
-
height=500, # Fixed height
|
| 165 |
)
|
| 166 |
elif column == ('CPIAUCSL', 'CPIAUCSL_PCT'):
|
| 167 |
# Plot inflation and its percentage change on dual y-axes
|
| 168 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data['CPIAUCSL'], mode='lines', name='Inflation (CPI)'))
|
| 169 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data['CPIAUCSL_PCT'], mode='lines', name='Inflation % Change', yaxis='y2'))
|
| 170 |
|
| 171 |
-
# Create a secondary y-axis and place the legend inside the plot
|
| 172 |
-
|
| 173 |
fig.update_layout(
|
| 174 |
yaxis2=dict(
|
| 175 |
title="Inflation % Change",
|
|
@@ -182,15 +170,14 @@ if st.sidebar.button('Run Analysis'):
|
|
| 182 |
traceorder='normal',
|
| 183 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 184 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 185 |
-
)
|
| 186 |
-
height=500, # Fixed height
|
| 187 |
)
|
| 188 |
elif column == ('GS10', 'DGS2', 'DGS1MO', 'TB3MS'):
|
| 189 |
# Plot multiple Treasury rates in the same subplot
|
| 190 |
for col in column:
|
| 191 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data[col], mode='lines', name=col))
|
| 192 |
|
| 193 |
-
# Place the legend inside the plot area
|
| 194 |
fig.update_layout(
|
| 195 |
legend=dict(
|
| 196 |
x=0.02,
|
|
@@ -198,8 +185,7 @@ if st.sidebar.button('Run Analysis'):
|
|
| 198 |
traceorder='normal',
|
| 199 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 200 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 201 |
-
)
|
| 202 |
-
height=500, # Fixed height
|
| 203 |
)
|
| 204 |
else:
|
| 205 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data[column], mode='lines', name=key))
|
|
@@ -227,8 +213,7 @@ if st.sidebar.button('Run Analysis'):
|
|
| 227 |
bgcolor="white",
|
| 228 |
font_size=12,
|
| 229 |
font_family="Rockwell"
|
| 230 |
-
)
|
| 231 |
-
height=500, # Fixed height
|
| 232 |
)
|
| 233 |
fig.update_xaxes(
|
| 234 |
showgrid=True,
|
|
@@ -248,11 +233,10 @@ if st.sidebar.button('Run Analysis'):
|
|
| 248 |
|
| 249 |
st.plotly_chart(fig, use_container_width=True)
|
| 250 |
|
| 251 |
-
# Hide Streamlit menu and footer
|
| 252 |
hide_streamlit_style = """
|
| 253 |
<style>
|
| 254 |
#MainMenu {visibility: hidden;}
|
| 255 |
footer {visibility: hidden;}
|
| 256 |
</style>
|
| 257 |
"""
|
| 258 |
-
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
|
|
|
| 61 |
'2020-02-01': '2020-04-01'
|
| 62 |
}
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
# Run button
|
| 65 |
if st.sidebar.button('Run Analysis'):
|
| 66 |
# Fetch the data from FRED
|
|
|
|
| 150 |
traceorder='normal',
|
| 151 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 152 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 153 |
+
)
|
|
|
|
| 154 |
)
|
| 155 |
elif column == ('CPIAUCSL', 'CPIAUCSL_PCT'):
|
| 156 |
# Plot inflation and its percentage change on dual y-axes
|
| 157 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data['CPIAUCSL'], mode='lines', name='Inflation (CPI)'))
|
| 158 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data['CPIAUCSL_PCT'], mode='lines', name='Inflation % Change', yaxis='y2'))
|
| 159 |
|
| 160 |
+
# Create a secondary y-axis and place the legend inside the plot area
|
|
|
|
| 161 |
fig.update_layout(
|
| 162 |
yaxis2=dict(
|
| 163 |
title="Inflation % Change",
|
|
|
|
| 170 |
traceorder='normal',
|
| 171 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 172 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 173 |
+
)
|
|
|
|
| 174 |
)
|
| 175 |
elif column == ('GS10', 'DGS2', 'DGS1MO', 'TB3MS'):
|
| 176 |
# Plot multiple Treasury rates in the same subplot
|
| 177 |
for col in column:
|
| 178 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data[col], mode='lines', name=col))
|
| 179 |
|
| 180 |
+
# Place the legend inside the plot area
|
| 181 |
fig.update_layout(
|
| 182 |
legend=dict(
|
| 183 |
x=0.02,
|
|
|
|
| 185 |
traceorder='normal',
|
| 186 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 187 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 188 |
+
)
|
|
|
|
| 189 |
)
|
| 190 |
else:
|
| 191 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data[column], mode='lines', name=key))
|
|
|
|
| 213 |
bgcolor="white",
|
| 214 |
font_size=12,
|
| 215 |
font_family="Rockwell"
|
| 216 |
+
)
|
|
|
|
| 217 |
)
|
| 218 |
fig.update_xaxes(
|
| 219 |
showgrid=True,
|
|
|
|
| 233 |
|
| 234 |
st.plotly_chart(fig, use_container_width=True)
|
| 235 |
|
|
|
|
| 236 |
hide_streamlit_style = """
|
| 237 |
<style>
|
| 238 |
#MainMenu {visibility: hidden;}
|
| 239 |
footer {visibility: hidden;}
|
| 240 |
</style>
|
| 241 |
"""
|
| 242 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|