Python matplotlib 画图 设置标题 大标题 副标题 大小、位置、粗细全集


设置标题大小
设置标题字体
设置标题位置
设置标题字体粗细
设置标题斜体

设置大标题大小
设置大标题字体
设置大标题位置
设置大标题字体粗细
设置大标题斜体

其实是大标题
设置副标题大小
设置副标题字体
设置副标题位置
设置副标题字体粗细
设置副标题斜体


from matplotlib import rcParams
import matplotlib.pyplot as plt

fig,axes = plt.subplots(1,1,figsize=(4,4),dpi=100,facecolor="w")
fig.subplots_adjust(left=0.2,bottom=0.2)

label_fontdict = {
    #'fontsize': rcParams['axes.titlesize'], # 设置成和轴刻度标签一样的大小
    'fontsize': 10,
    #'fontweight': rcParams['axes.titleweight'], # 设置成和轴刻度标签一样的粗细
    'fontweight': 'bold',
    #'color': rcParams['axes.titlecolor'], # 设置成和轴刻度标签一样的颜色
    'color': 'red',
    'verticalalignment': 'baseline',
    'horizontalalignment': 'left' # {'center', 'left', 'right'}
}
axes.set_title('title', fontdict=label_fontdict, loc='left', pad=0)

# x,y 控制suptitle标题的位置
# horizontalalignment 缩写ha 文本相对于(x, y)的水平对齐方式。{'center', 'left', 'right'}, default: center
# verticalalignment 缩写va 文本相对于(x, y)的垂直对齐方式。{'top', 'center', 'bottom', 'baseline'}, default: top
# fontweight default: 'normal'
fig.suptitle('suptitle', fontsize=24, x=0.6,y=0.9, horizontalalignment='left', va='bottom')
# 通过调整xy位置,和文字方向rotation,也可以将suptitle设置到y轴附近 

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
青葱年少的头像青葱年少普通用户
上一篇 2023年8月8日
下一篇 2023年8月8日

相关推荐