Adding images can sometimes be a more intuitive and attractive way to add annotations. We can place images in a AnnotationBbox, which is a container for annotations. Versatile settings allow easy pointing from the box to target.
There are a few steps in adding image annotations.
Firstly, we obtain the image, either by fetching it online or by saving it locally.
To get an online image, we use the urllib package:
import urllibimg_fetch = urllib.request.urlopen(url)
Then, we then call pyplot.imread(img_fetch, format) to read the image. For local images, put the path at the first argument. Common formats such as JPG and PNG are supported.
Next, we open an image box using imagebox = OffsetImage(img, zoom), where zoom