improvement, not much
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import pandas as pd
|
||||
import plotly.express as px
|
||||
import plotly.graph_objects as go
|
||||
|
||||
# Read the CSV file into a Pandas DataFrame
|
||||
@@ -12,12 +11,12 @@ columns_to_summarize = ["ancient", "old", "middle", "new", "late"]
|
||||
# Group the data by the "place" column and calculate sums within each group
|
||||
grouped = df.groupby("place")[columns_to_summarize].sum().reset_index()
|
||||
|
||||
# Create a bar chart using Plotly
|
||||
# Create a stacked bar chart using Plotly
|
||||
fig = go.Figure()
|
||||
|
||||
# Add a bar trace for each category
|
||||
for col in columns_to_summarize:
|
||||
fig.add_trace(go.Bar(x=grouped["place"], y=grouped[col], name=col))
|
||||
fig.add_trace(go.Bar(x=grouped["place"], y=grouped[col], name=col, text=grouped[col], textposition='auto'))
|
||||
|
||||
# Customize the layout
|
||||
fig.update_layout(
|
||||
@@ -25,7 +24,7 @@ fig.update_layout(
|
||||
xaxis_title="Place",
|
||||
yaxis_title="Total Count",
|
||||
xaxis=dict(categoryorder='total descending'),
|
||||
barmode='group'
|
||||
barmode='stack'
|
||||
)
|
||||
|
||||
# Enable selection by clicking
|
||||
|
Reference in New Issue
Block a user