Created
April 5, 2019 02:11
-
-
Save Ken-Kuroki/d8ed7f76988cae7610926d22936d5356 to your computer and use it in GitHub Desktop.
Generic scatterplot function for Altair
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot(df, x, y, args, fill=False): | |
df = df.reset_index() | |
index = df.columns[0] | |
if fill: | |
chart = alt.Chart(df).mark_circle(size=30) | |
else: | |
chart = alt.Chart(df).mark_point(size=30) | |
chart = chart.encode( | |
x=alt.X(x), | |
y=alt.Y(y), | |
tooltip=[index, x, y, *args.values()], | |
**args | |
).interactive() | |
return chart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment