Adding a Call to Action

Learn how to add a call to action to an Altair chart.

Incorporating a call to action (CTA) in a chart can help engage the audience and encourage them to take a specific action. Here are some techniques to include a CTA in a chart:

  • Add a clear and concise message.

  • Use contrasting colors to make it stand out and draw attention to it.

  • Make it interactive. If possible, make the CTA interactive so the audience can click on it or hover over it to learn more.

  • Use arrows or other visual cues to draw attention to the CTA.

  • Place the CTA in a prominent but logical position within the chart. For example, place the CTA at the end of a chart or after a section that provides context.

How to add a CTA in Altair

There are two principal methods to add a CTA into a chart: using a textual annotation and using the title.

Using a textual annotation

Incorporate the CTA as a textual annotation using the mark_text() method. This method lets us add a text label to our chart at a specified position. First, define the position using the x and y parameters.

The following example adds a textual annotation surrounded by a box to a chart.

Get hands-on with 1400+ tech skills courses.