higher graph
This commit is contained in:
17
ratios.py
17
ratios.py
@@ -17,9 +17,14 @@ columns_to_summarize = ["ancient", "old", "middle", "new", "late"]
|
|||||||
# Create the figure for the initial graph (placeholder data)
|
# Create the figure for the initial graph (placeholder data)
|
||||||
initial_data = df.groupby("place")[columns_to_summarize].sum().reset_index()
|
initial_data = df.groupby("place")[columns_to_summarize].sum().reset_index()
|
||||||
initial_fig = go.Figure()
|
initial_fig = go.Figure()
|
||||||
|
initial_fig.layout.height = 700 # You can set the desired height here
|
||||||
for col in columns_to_summarize:
|
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
|
# Define the app layout
|
||||||
app.layout = html.Div([
|
app.layout = html.Div([
|
||||||
@@ -34,6 +39,8 @@ app.layout = html.Div([
|
|||||||
])
|
])
|
||||||
|
|
||||||
# Define a callback to update the graph based on selected places
|
# Define a callback to update the graph based on selected places
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output("bar-graph", "figure"),
|
Output("bar-graph", "figure"),
|
||||||
[Input("place-selector", "value")]
|
[Input("place-selector", "value")]
|
||||||
@@ -41,7 +48,7 @@ app.layout = html.Div([
|
|||||||
def update_graph(selected_places):
|
def update_graph(selected_places):
|
||||||
filtered_df = df[df["place"].isin(selected_places)]
|
filtered_df = df[df["place"].isin(selected_places)]
|
||||||
grouped = filtered_df.groupby("place")[columns_to_summarize].sum().reset_index()
|
grouped = filtered_df.groupby("place")[columns_to_summarize].sum().reset_index()
|
||||||
|
|
||||||
fig = go.Figure()
|
fig = go.Figure()
|
||||||
|
|
||||||
for col in columns_to_summarize:
|
for col in columns_to_summarize:
|
||||||
@@ -53,7 +60,11 @@ def update_graph(selected_places):
|
|||||||
total = grouped[columns_to_summarize].iloc[index].sum()
|
total = grouped[columns_to_summarize].iloc[index].sum()
|
||||||
fig.add_annotation(text=f"Total: {total}", x=place, y=total + 5)
|
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
|
return fig
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run_server(debug=True)
|
app.run_server(debug=True)
|
||||||
|
Reference in New Issue
Block a user