Vertical faceted chart in Altair

Question:

I need to create a faceted chart in altair. I am using the example given in this link (https://altair-viz.github.io/user_guide/compound_charts.html) which places charts horizontally. The code is

import altair as alt

from vega_datasets import data
iris = data.iris.url
alt.Chart(iris).mark_point().encode(
    x='petalLength:Q',
    y='petalWidth:Q',
    color='species:N',
    column='species:N'
).properties(
    width=180,
    height=180
)

Result – enter image description here

My question is if it is possible to get the same charts but vertically. The output required is similar to the one answered by @jakevdp for this question (Altair facet charts save individual image) but without the need to create separate charts.
Screenshot – enter image description here

Thanks

Asked By: Green Finance

||

Answers:

Yes, just change column to row.

import altair as alt

from vega_datasets import data
iris = data.iris.url
alt.Chart(iris).mark_point().encode(
    x='petalLength:Q',
    y='petalWidth:Q',
    color='species:N',
    row='species:N'
).properties(
    width=180,
    height=180
)
Answered By: David
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.