Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 642
Ragnar Lothbrok Avatar asked Feb 24 '19 18:02

Ragnar Lothbrok


People also ask

How do I change my Altair scale?

By default Altair uses a linear mapping between the domain values (MIC) and the range values (pixels). To get a better overview of the data, we can apply a different scale transformation. To change the scale type, we'll set the scale attribute, using the alt. Scale method and type parameter.

How do I remove the legend from Altair?

You can remove the legend entirely by submitting a null value.

How do I get rid of gridlines on Altair?

We can remove the grid lines on x or y-axis by specifying the argument grid=False inside alt. X() or alt. Y() method in the encoding channels.


1 Answers

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)
like image 155
jakevdp Avatar answered Sep 21 '22 11:09

jakevdp