Choosing Size

Learn how to choose and set size in Altair.

We'll cover the following

When creating a chart, the size of the chart can significantly affect how the audience perceives our data. Size impacts our visual representation’s readability and overall impact and effectiveness.

Choosing an appropriate size for our chart depends on multiple factors, such as where we will display it, what kind of content we want to show, and who will view it. The best way to determine the correct size is through experimentation; we can try different sizes until we land on one that looks good enough.

Moreover, choosing a smaller or larger chart affects how much information can fit into one frame without cluttering text together. It also influences how easily readers can read all data points without straining their eyes or getting lost in too many elements.

In a chart, you can configure two types of sizes:

  • Font size

  • Chart size

Font size

Font size is an essential aspect of any chart, because it directly affects the readability and comprehensibility of the data. The font size should be set to make it easy for the reader to understand and interpret the information presented in the chart.

When setting up a chart, we can specify different font sizes for different chart components like titles, axis labels, or tick labels. A good practice is to keep them consistent throughout our plot so that they look visually appealing and organized.

The font size of a chart is a crucial factor in conveying information. By default, Altair sets the font size to 12px. However, we can adjust the font size to make our charts more legible or match the style.

To change the font size in Altair, we identify which part of our visualization we want to modify. Once identified, we’ll use Altair’s configure_*() method along with the axis, title, text, or legend property, based on which component we want to modify. We can then pass parameters like fontSize or labelFontSize along with their desired value.

Consider the following example that sets the title font size and label font size of both axes in a chart:

Get hands-on with 1200+ tech skills courses.