Skip to content

Commit

Permalink
feat: adds base code to plot boxplot with facet option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukund Iyer committed Jan 18, 2022
1 parent 952d042 commit 65b6b66
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/magmaviz/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,21 @@ def boxplot(df, x, y, facet=False):
Examples
--------
>>> from magmaviz.magmaviz import boxplot
>>> boxplot(mtcars, horsepower, cars, facet=True)
>>> boxplot(cars, "Miles_per_Gallon", "Origin", facet=True)
"""
# crete the plot object
plot = (
alt.Chart(df)
.mark_boxplot()
.encode(
x=alt.X(x, title=x),
y=alt.Y(y, title=y),
color=alt.Color(y, scale=alt.Scale(scheme="magma")),
)
)

# facet if needed
if facet == True:
return plot.facet(row=y)
else:
return plot

0 comments on commit 65b6b66

Please sign in to comment.