【问题标题】:Bold title - subplots粗体标题 - 子图
【发布时间】:2020-04-13 03:48:48
【问题描述】:

我有一个带有设置字体参数的子图脚本。如何让 fig1.set_title 加粗?谢谢

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D                 # 3d graph
from mpl_toolkits.mplot3d import proj3d                 # 3d graph   
plt.rcParams['text.latex.preamble']=[r"\usepackage{lmodern}"]
plt.rcParams['text.latex.preamble']=[r"\usepackage{bm}"]
params = {'text.usetex' : True,
          'font.size' : 28,
          'font.family' : 'lmodern',
          'text.latex.unicode': True,
          }
plt.rcParams.update(params)
# Plot subplot 
fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 2, figsize=(10,13))
fig1 = plt.subplot(421)
fig1.set_title('AAAAA \n +', fontweight='bold', color='red', pad=50)
plt.axis('off')
fig2 = plt.subplot(422)
fig3 = plt.subplot(423, projection = '3d') 
fig4=plt.subplot(424)
fig5=plt.subplot(425)
fig6=plt.subplot(426)
fig7=plt.subplot(427)
fig8=plt.subplot(428)
plt.tight_layout()
plt.show()

【问题讨论】:

标签: matplotlib python-3.6


【解决方案1】:

试试:

def setBold(txt): return r"$\bf{" + str(txt) + "}$"

plt.title(setBold("AAAAA") + '\n' + setBold('+'))

问题来自"\n"Putting newline in matplotlib label with TeX 建议将 \n 与 Latex 格式分开。

希望有帮助!

【讨论】:

  • 非常感谢,它有帮助。加号也可以用粗体写吗?
猜你喜欢
  • 1970-01-01
  • 2020-09-27
  • 2022-01-25
  • 1970-01-01
  • 2021-02-19
  • 2017-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多