Reputation: 1451
I would like to have multiple title in my graph. A picture is better than anyword :
I use a title
for every graph (D2/E, D3/E and D4/E) and a suptitle
for title 1 and 2 but they have the same font size. Is there a solution to have different size for Title 1 and Title 2 ?
I've already seen this solution using LaTeX but the thing is when I use plt.rc('text', usetex=True)
every font and text are changed. Moreover, I use variable in each title and it looks like I can't do it with LaTeX.
Upvotes: 8
Views: 10762
Reputation: 25400
You can use matplotlib.pyplot.text
objects in order to achieve the same result. Note that you need to make sure you use the figure coordinate system by using the transform=fig.transFigure
argument and set the horizontal alignment using ha = "center"
An example:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1,3)
plt.text(x=0.5, y=0.94, s="My title 1", fontsize=18, ha="center", transform=fig.transFigure)
plt.text(x=0.5, y=0.88, s= "My title 2 in different size", fontsize=12, ha="center", transform=fig.transFigure)
for i, ax in enumerate(axes.flatten()):
ax.set_title("D{}/E".format(i))
plt.subplots_adjust(top=0.8, wspace=0.3)
plt.show()
Upvotes: 15