This section describes how we can add text to both the axis and figure objects, including adding text in multi-panel figures and configuring the appearance of text.
Adding text on your plots
Adding text to both axis and figure objects
Let's start by importing everything we need:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
# Set up figure size and DPI for screen demo
plt.rcParams['figure.figsize'] = (6,4)
plt.rcParams['figure.dpi'] = 150
- Next, bring up the standard sine curve that we have been using:
# Add some text
nums = np.arange(0,10,0.1)
plt.plot(nums, np.sin(nums))
We will get the following output:
- We will add some text, say, right in the middle...