Python Matplotlib在一个标签中提供多种字体大小 [英] Python Matplotlib multiple font sizes in one label

查看:240
本文介绍了Python Matplotlib在一个标签中提供多种字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Matplotlib.pyplot在IPython IDE中进行绘图,并添加了带有以下内容的标题:

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)

但是,我希望第一行的大小为40,第二行的大小为18.在matplotlib中可以吗?我看到了\tiny\Huge的乳胶用法,但是想要更多的控制.

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.

谢谢, 亚伦

推荐答案

尝试:

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

\r可能希望成为您系统上的\n.

That \r might want to be a \n on your system.

我使用了 Joel的答案来解决您的问题.

这篇关于Python Matplotlib在一个标签中提供多种字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆