-
Notifications
You must be signed in to change notification settings - Fork 766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subplots #206
Comments
Yes! This feature will be supported by Vega Lite in the upcoming release, and we'll have Altair bindings for it as soon as possible once that's available. |
You can also use |
+1 this is a really great project. Re subplots , matplotlib requires you specify the layout in advance and the grid coordinates for each chart. One thing I do a lot is to call multiple functions which collectively show 20-40 unrelated charts. I don't know the layout in advance as I don't know how many charts I will have in total; and within a function when I print a chart I don't have the context so I don't know the position in the grid. I just know that 10 rows of 4 charts is neater than a big long list of 40 charts. So I want a one liner to start "gridprint"; and then all subsequent charts take the next place in the grid. Would be great if you could do that.....Maybe this is in the vega spec but could not see it. |
Closing as vega-lite-related |
Seaborn has a one-liner for subplots, no need to specify layout. |
Altair does create these kinds of faceted subplots automatically. If you take the above dataframe and put it into the long-form format used by Altair, it can be done with a straightforward set of encodings: import altair as alt
# Make data long-form
data = diff_ccgs.melt().reset_index()
alt.Chart(data).mark_line().encode(
x='index',
y='value',
color='variable',
column='variable'
) |
Thanks, but reset_index, which is necessary for melting here, is an issue as the data is an excerpt from a time series. |
Why is that an issue? If you want the index to be on the x axis, you need to make it an explicit column (using |
If the index is named, then it will keep its original name rather than being called |
You might need to switch the order in order to keep the index; e.g. diff_ccgs.reset_index().melt('index') The point is to get whatever data you want to plot into the appropriate long-form representation. The pandas manipulations are up to you 😄 |
You're right, no issues! (I tried pd.melt but your line worked better). However, I'm getting the charts in a long row so to come back to the matplotlib-like question, can we specify a layout? I also draw many plots and want them say in a 2 * 5 layout. |
It can be done, but not easily (you can transform the data in order to generate new encodings that map to the rows & columns you want). It will be much easier when wrapped facets land in Vega-Lite; see vega/vega-lite#393 to track progress on that. |
Hi guys,
any plans to add the ability to generate multiple charts ? (matplotlib's subplot equivalent)
PS. This project is just amazing !
The text was updated successfully, but these errors were encountered: