Altair’s configure_*() methods apply presentation settings to chart components. Use configure_view() for the chart’s general view, while related methods target axes, titles, text, or legends. section 3.2.6 section 8.3.1
Use configuration deliberately to improve clarity without overwhelming the visualization:
- Remove or adjust the view border with strokeWidth and stroke. section 3.2.6
- Set the view background with fill. section 3.2.6
- Use configure_view(width=..., height=...) when sizing single or compound charts; use properties(width=..., height=...) for single charts. section 8.3.2
- Coordinate view settings with configure_axis() and configure_title() so the whole chart has a consistent visual treatment. section 3.3.1
Remove the default view border
chart = chart.configure_view( strokeWidth=0, stroke='#80C11E', fill='#E0E0E0' ) chart.save('configure-view.html') Here, strokeWidth removes the border, stroke sets its color if present, and fill changes the general view background. Compare the result with the default chart to judge whether the styling supports the intended reading. section 3.2.6
Listing 3.22 Configuring view
chart = chart.configure_view(
strokeWidth=0, #1
stroke='#80C11E', #2
fill='#E0E0E0' #3
)
chart.save('configure-view.html')
Inspect the complete configure_view() listing and its corresponding before-and-after layout comparison. section 3.2.6
