79269982

Date: 2024-12-10 22:29:49
Score: 0.5
Natty:
Report link

Altair has the ability to resolve each axes' scale independently:

working image

import altair as alt
import pandas as pd

# Sample data
data = {
    'Group': ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C'],
    'Category': ['A1', 'A2', 'A3', 'B1', 'B2', 'B3', 'C1', 'C2', 'C3'],
    'Value': [10, 15, 7, 8, 12, 18, 12, 10, 9]
}

df = pd.DataFrame(data)

# Create the grouped bar chart
chart = alt.Chart(df).mark_bar().encode(
    x=alt.X('Category:N', title='Category'),
    y=alt.Y('Value:Q', title='Value'),
    column=alt.Column('Group:N', title='Group')
)

chart.resolve_scale(x='independent')
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: kgoodrick