Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vertical faceted chart in Altair

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks

>Solution :

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
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading