I'm plotting in an IPython IDE using Matplotlib.pyplot
and added a title with:
plt.title('Mean WRFv3.5 LHF\n(September 16 - October 30, 2012)', fontsize=40)
However, I want the first line to be size 40 and the second line to be size 18. Is that possible in matplotlib
? I saw the LaTeX use of \tiny
and \Huge
, but would like more control.
Do not use hyphenations for the end of a line. Center the title. Only the first letter in the title is capitalized, except for proper names, elements and abbreviations. The title should be in 18 pt., bold font.
Plot x data points using plot() method. To change the font size of the scale in matplotlib, we can use labelsize in the ticks_params()method. To display the figure, use show() method.
Try:
import matplotlib.pyplot as plt
plt.rc('text', usetex=True)
plt.title(r'\fontsize{30pt}{3em}\selectfont{}{Mean WRFv3.5 LHF\r}{\fontsize{18pt}{3em}\selectfont{}(September 16 - October 30, 2012)}')
plt.show()
That \r
might want to be a \n
on your system.
I used Joel's answer to address your question.
Not sure if this is what you want, but you may add a suptitle or text and set at different fontsize like this:
plt.title('Mean WRFv3.5 LHF\n', fontsize=40)
plt.suptitle('(September 16 - October 30, 2012)\n', fontsize=18)
plt.text(0.5, 1, 'the third line', fontsize=13, ha='center')
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With