Is there any matplotlib function to create a growth arrow between two points in a chart?

I was wondering if its possible to plot in a bar chart or in a line chart an arrow between two points of the charts. Something like the following picture:

enter image description here

I’ve been looking for something like this but haven’t found anything similar neither here on stackoverflow nor on any other website.

Thanks a lot for your help!


There isn’t any built-in matplotlib function to do this, but you can construct the annotations yourself using an arrow and a bbox. You can also wrap this code up in a function between any two data points to make this more generalizable.

import matplotlib.pyplot as plt


fig, ax = plt.subplots(figsize=(12,8)),y)

## add the text above the bars
for idx, value in enumerate(x):
    ax.text(value, y[idx]+1, str(y[idx]))

## add the bar style connection patch, padding the y-coordinates
t = ax.annotate("",
            xy=(x[0], y[0]+5), xycoords='data',
            xytext=(x[-1], y[-1]+5), textcoords='data',
            arrowprops=dict(arrowstyle="<-", color="0.5",
                            shrinkA=5, shrinkB=5,
                            patchA=None, patchB=None,

props = dict(boxstyle='round', facecolor="white")

# place a text box in upper left in axes coords
growth = "600%"
ax.text("d", 240*1.18, growth, bbox=props)

## pretty up the chart by removing axes

enter image description here