Skip to content

Commit 2beb26b

Browse files
fix(letsplot): address review feedback for bar-basic
Attempt 1/3 - fixes based on AI review
1 parent ed02818 commit 2beb26b

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

plots/bar-basic/implementations/letsplot.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,26 @@
1111
LetsPlot.setup_html() # noqa: F405
1212

1313
# Data - Product sales by category
14-
categories = ["Electronics", "Clothing", "Home & Garden", "Sports", "Books", "Toys", "Food & Beverage"]
15-
values = [45200, 32800, 28500, 21300, 18700, 15400, 12100]
14+
categories = ["Electronics", "Clothing", "Home & Garden", "Sports", "Books", "Toys"]
15+
values = [45200, 32800, 28500, 21300, 18900, 15600]
1616

1717
df = pd.DataFrame({"category": categories, "value": values})
1818

19+
# Preserve category order
20+
df["category"] = pd.Categorical(df["category"], categories=categories, ordered=True)
21+
1922
# Plot
2023
plot = (
2124
ggplot(df, aes(x="category", y="value")) # noqa: F405
22-
+ geom_bar(stat="identity", fill="#306998", width=0.7) # noqa: F405
25+
+ geom_bar(stat="identity", fill="#306998", width=0.6) # noqa: F405
26+
+ geom_text( # noqa: F405
27+
aes(label="value"), # noqa: F405
28+
position=position_nudge(y=1500), # noqa: F405
29+
size=14,
30+
label_format="${,}",
31+
)
2332
+ labs(x="Product Category", y="Sales ($)", title="Product Sales by Category") # noqa: F405
33+
+ scale_y_continuous(limits=[0, 55000]) # noqa: F405
2434
+ ggsize(1600, 900) # noqa: F405
2535
+ theme_minimal() # noqa: F405
2636
+ theme( # noqa: F405

0 commit comments

Comments
 (0)