diff --git a/ratios.py b/ratios.py index dea67c3..60ac75a 100644 --- a/ratios.py +++ b/ratios.py @@ -17,9 +17,14 @@ columns_to_summarize = ["ancient", "old", "middle", "new", "late"] # Create the figure for the initial graph (placeholder data) initial_data = df.groupby("place")[columns_to_summarize].sum().reset_index() initial_fig = go.Figure() - +initial_fig.layout.height = 700 # You can set the desired height here for col in columns_to_summarize: - initial_fig.add_trace(go.Bar(name=col, x=initial_data["place"], y=initial_data[col], text=initial_data[col], textposition="auto")) + initial_fig.add_trace( + go.Bar( + name=col, x=initial_data["place"], + y=initial_data[col], + text=initial_data[col], + textposition="auto")) # Define the app layout app.layout = html.Div([ @@ -34,6 +39,8 @@ app.layout = html.Div([ ]) # Define a callback to update the graph based on selected places + + @app.callback( Output("bar-graph", "figure"), [Input("place-selector", "value")] @@ -41,7 +48,7 @@ app.layout = html.Div([ def update_graph(selected_places): filtered_df = df[df["place"].isin(selected_places)] grouped = filtered_df.groupby("place")[columns_to_summarize].sum().reset_index() - + fig = go.Figure() for col in columns_to_summarize: @@ -53,7 +60,11 @@ def update_graph(selected_places): total = grouped[columns_to_summarize].iloc[index].sum() fig.add_annotation(text=f"Total: {total}", x=place, y=total + 5) + # Adjust the height of the plot area + fig.update_layout(height=700) # You can set the desired height here + return fig + if __name__ == "__main__": app.run_server(debug=True)