QuantumLearner commited on
Commit
d79f727
·
verified ·
1 Parent(s): b94325f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -17
app.py CHANGED
@@ -142,9 +142,7 @@ if st.sidebar.button('Run Analysis'):
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,6 +151,9 @@ if st.sidebar.button('Run Analysis'):
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,9 +165,7 @@ if st.sidebar.button('Run Analysis'):
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,6 +174,9 @@ if st.sidebar.button('Run Analysis'):
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,6 +192,9 @@ if st.sidebar.button('Run Analysis'):
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,18 +209,14 @@ if st.sidebar.button('Run Analysis'):
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,7 +225,7 @@ if st.sidebar.button('Run Analysis'):
224
  ),
225
  autosize=True,
226
  margin=dict(l=50, r=50, t=50, b=50),
227
- height=600, # Set a maximum height
228
  )
229
  fig.update_xaxes(
230
  showgrid=True,
@@ -232,8 +233,8 @@ if st.sidebar.button('Run Analysis'):
232
  gridcolor='LightGray',
233
  tickangle=45,
234
  tickformatstops=[
235
- dict(dtickrange=[None, "M1"], value="%b %d, %Y"),
236
- dict(dtickrange=["M1", None], value="%Y")
237
  ]
238
  )
239
 
@@ -242,7 +243,7 @@ if st.sidebar.button('Run Analysis'):
242
  hovertemplate='%{x|%b %d, %Y}<br>%{y}<extra></extra>'
243
  )
244
 
245
- st.plotly_chart(fig, use_container_width=True, config={'responsive': True})
246
 
247
  # Hide Streamlit menu and footer
248
  hide_streamlit_style = """
@@ -251,4 +252,4 @@ hide_streamlit_style = """
251
  footer {visibility: hidden;}
252
  </style>
253
  """
254
- st.markdown(hide_streamlit_style, unsafe_allow_html=True)
 
142
  yaxis2=dict(
143
  title="Industrial Production % Change",
144
  overlaying='y',
145
+ side='right'
 
 
146
  ),
147
  legend=dict(
148
  x=0.02,
 
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
  yaxis2=dict(
166
  title="Inflation % Change",
167
  overlaying='y',
168
+ side='right'
 
 
169
  ),
170
  legend=dict(
171
  x=0.02,
 
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
  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
  xaxis_title='Date',
210
  yaxis_title=key,
211
  xaxis=dict(
212
+ tickformat="%Y", # Yearly ticks
213
  tickmode="linear",
214
+ dtick="M36", # Ticks every 12 months, M24 Every 2 years and 5 years is M60
215
  showspikes=True,
216
  spikemode='across',
217
  spikesnap='cursor',
218
  spikethickness=1
219
  ),
 
 
 
 
220
  hovermode="x unified",
221
  hoverlabel=dict(
222
  bgcolor="white",
 
225
  ),
226
  autosize=True,
227
  margin=dict(l=50, r=50, t=50, b=50),
228
+ height=400, # Reduced height
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"), # Format as "Month Day, Year" for better granularity
237
+ dict(dtickrange=["M1", None], value="%Y") # Year format for larger intervals
238
  ]
239
  )
240
 
 
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
  footer {visibility: hidden;}
253
  </style>
254
  """
255
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)