Skip to content

Commit 1ac532d

Browse files
feat(plotnine): implement scatter-color-groups
Adds plotnine implementation for scatter plot with color groups. Uses the iris dataset to demonstrate categorical color grouping with sepal measurements colored by species.
1 parent 27357ca commit 1ac532d

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • plots/plotnine/point/scatter-color-groups
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
scatter-color-groups: Scatter Plot with Color Groups
3+
Library: plotnine
4+
"""
5+
6+
import seaborn as sns
7+
from plotnine import aes, geom_point, ggplot, labs, scale_color_brewer, theme, theme_minimal
8+
9+
10+
# Data
11+
data = sns.load_dataset("iris")
12+
13+
# Create plot
14+
plot = (
15+
ggplot(data, aes(x="sepal_length", y="sepal_width", color="species"))
16+
+ geom_point(size=3, alpha=0.7)
17+
+ labs(x="Sepal Length (cm)", y="Sepal Width (cm)", title="Scatter Plot with Color Groups", color="Species")
18+
+ scale_color_brewer(type="qual", palette="Set2")
19+
+ theme_minimal()
20+
+ theme(figure_size=(16, 9))
21+
)
22+
23+
# Save
24+
plot.save("plot.png", dpi=300)

0 commit comments

Comments
 (0)