13

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?

Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
Ragnar Lothbrok
  • 1,045
  • 2
  • 16
  • 31

1 Answers1

19

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)
jakevdp
  • 77,104
  • 11
  • 125
  • 160