'Altair Grouped Bar Chart With Multiple Conditions
I have this DataFrame called table:
TERM Bitcoin S&P500 Real Estate Gold
0 High-Inflation/ Short term 3097.94 -3700.78 761.23 6512.71
1 High-Inflation/ Mid term — -3080.01 -8434.66 3242.40
2 High-Inflation/ Long term — -2089.25 -9117.96 8174.43
3 Low-Inflation/ Short term 780200.00 -273.71 1824.72 2214.51
4 Low-Inflation/ Mid term 21013600.00 5331.40 35810.58 -2879.37
5 Low-Inflation/ Long term 978017143.00. 15045.41 35895.81 861.90
And I want to make a grouped (or stacked) bar chart that distinguishes return on investments for each of these assets based on the TERM column. I have tried this:
alt.Chart(table).transform_fold(
["Bitcoin", "S&P500", "Real Estate", "Gold"], as_=["key", "value"]
).mark_bar().encode(
x="key:N",
y="value:Q",
color="key:N",
column="TERM",
)
But that doesn't work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
