8

I would like to have multiple title in my graph. A picture is better than anyword : enter image description here

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.

1 Answer 1

15

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() 

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

I tried this solution but without using 'transform=fig.transFigure', it wasn't working well, thanks a lot!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.