Ragnar Lothbrok
Ragnar Lothbrok

Reputation: 1135

Increase Font Size of Chart Title in Altair

I can't figure out how to increase the size of the font for the chart title in Altair. My code will only change the font size for the axis titles, but not for the chart title.

Here's what I tested out:

data = df
bars = alt.Chart(data, title="This is the Chart Title").mark_bar().encode(
    x = 'Feature1',
    y = 'Feature2',
    color = alt.Color('Feature1', legend=None)).configure_axis(
    labelFontSize=16,
    titleFontSize=16
)

bars

In this instance, the titleFontSize argument changes the font for the axis titles ('Feature1' and 'Feature2' in this example). Is there any easy way to increase the font for the chart title?

Upvotes: 15

Views: 18352

Answers (1)

jakevdp
jakevdp

Reputation: 86330

When you call configure_axis, you are only configuring properties related to the axis. If you want to configure the properties of the chart title, you can use configure_title(); e.g.

bars.configure_title(fontSize=24)

Upvotes: 20

Related Questions