Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,7 +93,7 @@ if st.sidebar.button('Run Analysis'):
|
|
| 93 |
|
| 94 |
# Rename columns for clarity
|
| 95 |
industrial_production_pct = industrial_production_pct.rename(columns={'INDPRO': 'INDPRO_PCT'})
|
| 96 |
-
inflation_pct = inflation_pct.rename(columns
|
| 97 |
|
| 98 |
# Combine all data into a single DataFrame, aligning by date
|
| 99 |
combined_data = sahm_recession_indicator.join([
|
|
@@ -142,7 +142,9 @@ if st.sidebar.button('Run Analysis'):
|
|
| 142 |
yaxis2=dict(
|
| 143 |
title="Industrial Production % Change",
|
| 144 |
overlaying='y',
|
| 145 |
-
side='right'
|
|
|
|
|
|
|
| 146 |
),
|
| 147 |
legend=dict(
|
| 148 |
x=0.02,
|
|
@@ -151,9 +153,6 @@ if st.sidebar.button('Run Analysis'):
|
|
| 151 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 152 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 153 |
),
|
| 154 |
-
autosize=True,
|
| 155 |
-
margin=dict(l=50, r=50, t=50, b=50),
|
| 156 |
-
height=400, # Reduced height
|
| 157 |
)
|
| 158 |
elif column == ('CPIAUCSL', 'CPIAUCSL_PCT'):
|
| 159 |
# Plot inflation and its percentage change on dual y-axes
|
|
@@ -165,7 +164,9 @@ if st.sidebar.button('Run Analysis'):
|
|
| 165 |
yaxis2=dict(
|
| 166 |
title="Inflation % Change",
|
| 167 |
overlaying='y',
|
| 168 |
-
side='right'
|
|
|
|
|
|
|
| 169 |
),
|
| 170 |
legend=dict(
|
| 171 |
x=0.02,
|
|
@@ -174,9 +175,6 @@ if st.sidebar.button('Run Analysis'):
|
|
| 174 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 175 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 176 |
),
|
| 177 |
-
autosize=True,
|
| 178 |
-
margin=dict(l=50, r=50, t=50, b=50),
|
| 179 |
-
height=400, # Reduced height
|
| 180 |
)
|
| 181 |
elif column == ('GS10', 'DGS2', 'DGS1MO', 'TB3MS'):
|
| 182 |
# Plot multiple Treasury rates in the same subplot
|
|
@@ -192,9 +190,6 @@ if st.sidebar.button('Run Analysis'):
|
|
| 192 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 193 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 194 |
),
|
| 195 |
-
autosize=True,
|
| 196 |
-
margin=dict(l=50, r=50, t=50, b=50),
|
| 197 |
-
height=400, # Reduced height
|
| 198 |
)
|
| 199 |
else:
|
| 200 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data[column], mode='lines', name=key))
|
|
@@ -209,14 +204,18 @@ if st.sidebar.button('Run Analysis'):
|
|
| 209 |
xaxis_title='Date',
|
| 210 |
yaxis_title=key,
|
| 211 |
xaxis=dict(
|
| 212 |
-
tickformat="%Y",
|
| 213 |
tickmode="linear",
|
| 214 |
-
dtick="M36",
|
| 215 |
showspikes=True,
|
| 216 |
spikemode='across',
|
| 217 |
spikesnap='cursor',
|
| 218 |
spikethickness=1
|
| 219 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
hovermode="x unified",
|
| 221 |
hoverlabel=dict(
|
| 222 |
bgcolor="white",
|
|
@@ -225,7 +224,8 @@ if st.sidebar.button('Run Analysis'):
|
|
| 225 |
),
|
| 226 |
autosize=True,
|
| 227 |
margin=dict(l=50, r=50, t=50, b=50),
|
| 228 |
-
height=
|
|
|
|
| 229 |
)
|
| 230 |
fig.update_xaxes(
|
| 231 |
showgrid=True,
|
|
@@ -233,8 +233,8 @@ if st.sidebar.button('Run Analysis'):
|
|
| 233 |
gridcolor='LightGray',
|
| 234 |
tickangle=45,
|
| 235 |
tickformatstops=[
|
| 236 |
-
dict(dtickrange=[None, "M1"], value="%b %d, %Y"),
|
| 237 |
-
dict(dtickrange=["M1", None], value="%Y")
|
| 238 |
]
|
| 239 |
)
|
| 240 |
|
|
@@ -243,7 +243,7 @@ if st.sidebar.button('Run Analysis'):
|
|
| 243 |
hovertemplate='%{x|%b %d, %Y}<br>%{y}<extra></extra>'
|
| 244 |
)
|
| 245 |
|
| 246 |
-
st.plotly_chart(fig, use_container_width=True)
|
| 247 |
|
| 248 |
# Hide Streamlit menu and footer
|
| 249 |
hide_streamlit_style = """
|
|
@@ -252,4 +252,4 @@ hide_streamlit_style = """
|
|
| 252 |
footer {visibility: hidden;}
|
| 253 |
</style>
|
| 254 |
"""
|
| 255 |
-
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
|
|
|
| 93 |
|
| 94 |
# Rename columns for clarity
|
| 95 |
industrial_production_pct = industrial_production_pct.rename(columns={'INDPRO': 'INDPRO_PCT'})
|
| 96 |
+
inflation_pct = inflation_pct.rename(columns={'CPIAUCSL': 'CPIAUCSL_PCT'})
|
| 97 |
|
| 98 |
# Combine all data into a single DataFrame, aligning by date
|
| 99 |
combined_data = sahm_recession_indicator.join([
|
|
|
|
| 142 |
yaxis2=dict(
|
| 143 |
title="Industrial Production % Change",
|
| 144 |
overlaying='y',
|
| 145 |
+
side='right',
|
| 146 |
+
fixedrange=False,
|
| 147 |
+
autorange=True,
|
| 148 |
),
|
| 149 |
legend=dict(
|
| 150 |
x=0.02,
|
|
|
|
| 153 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 154 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 155 |
),
|
|
|
|
|
|
|
|
|
|
| 156 |
)
|
| 157 |
elif column == ('CPIAUCSL', 'CPIAUCSL_PCT'):
|
| 158 |
# Plot inflation and its percentage change on dual y-axes
|
|
|
|
| 164 |
yaxis2=dict(
|
| 165 |
title="Inflation % Change",
|
| 166 |
overlaying='y',
|
| 167 |
+
side='right',
|
| 168 |
+
fixedrange=False,
|
| 169 |
+
autorange=True,
|
| 170 |
),
|
| 171 |
legend=dict(
|
| 172 |
x=0.02,
|
|
|
|
| 175 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 176 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 177 |
),
|
|
|
|
|
|
|
|
|
|
| 178 |
)
|
| 179 |
elif column == ('GS10', 'DGS2', 'DGS1MO', 'TB3MS'):
|
| 180 |
# Plot multiple Treasury rates in the same subplot
|
|
|
|
| 190 |
bgcolor='rgba(255, 255, 255, 0.5)',
|
| 191 |
bordercolor='rgba(0, 0, 0, 0)'
|
| 192 |
),
|
|
|
|
|
|
|
|
|
|
| 193 |
)
|
| 194 |
else:
|
| 195 |
fig.add_trace(go.Scatter(x=combined_data.index, y=combined_data[column], mode='lines', name=key))
|
|
|
|
| 204 |
xaxis_title='Date',
|
| 205 |
yaxis_title=key,
|
| 206 |
xaxis=dict(
|
| 207 |
+
tickformat="%Y",
|
| 208 |
tickmode="linear",
|
| 209 |
+
dtick="M36",
|
| 210 |
showspikes=True,
|
| 211 |
spikemode='across',
|
| 212 |
spikesnap='cursor',
|
| 213 |
spikethickness=1
|
| 214 |
),
|
| 215 |
+
yaxis=dict(
|
| 216 |
+
fixedrange=False,
|
| 217 |
+
autorange=True,
|
| 218 |
+
),
|
| 219 |
hovermode="x unified",
|
| 220 |
hoverlabel=dict(
|
| 221 |
bgcolor="white",
|
|
|
|
| 224 |
),
|
| 225 |
autosize=True,
|
| 226 |
margin=dict(l=50, r=50, t=50, b=50),
|
| 227 |
+
height=600, # Set a maximum height
|
| 228 |
+
responsive=True,
|
| 229 |
)
|
| 230 |
fig.update_xaxes(
|
| 231 |
showgrid=True,
|
|
|
|
| 233 |
gridcolor='LightGray',
|
| 234 |
tickangle=45,
|
| 235 |
tickformatstops=[
|
| 236 |
+
dict(dtickrange=[None, "M1"], value="%b %d, %Y"),
|
| 237 |
+
dict(dtickrange=["M1", None], value="%Y")
|
| 238 |
]
|
| 239 |
)
|
| 240 |
|
|
|
|
| 243 |
hovertemplate='%{x|%b %d, %Y}<br>%{y}<extra></extra>'
|
| 244 |
)
|
| 245 |
|
| 246 |
+
st.plotly_chart(fig, use_container_width=True, config={'responsive': True})
|
| 247 |
|
| 248 |
# Hide Streamlit menu and footer
|
| 249 |
hide_streamlit_style = """
|
|
|
|
| 252 |
footer {visibility: hidden;}
|
| 253 |
</style>
|
| 254 |
"""
|
| 255 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|