python画图图例字体

编程入门 行业动态 更新时间:2024-10-07 01:28:31

python<a href=https://www.elefans.com/category/jswz/34/1769620.html style=画图图例字体"/>

python画图图例字体

通过prop参数将FontProperties对象(如下面的font)传递给ax.legend:import matplotlib.pyplot as plt

import numpy as np

import matplotlib.font_manager as font_manager

fig, ax = plt.subplots()

x = np.linspace(-10, 10, 100)

ax.plot(np.sin(x)/x, label='Mexican hat')

font = font_manager.FontProperties(family='Comic Sans MS',

weight='bold',

style='normal', size=16)

ax.legend(prop=font)

plt.show()

在Ubuntu上,你可以通过运行fc-cache -f -v /path/to/fonts/directory

我不确定在其他操作系统上是如何实现的,也不知道在其他类型的Unix上是如何通用的。

一旦您安装了字体以便操作系统了解它们,您就可以通过删除~/.cache/fontconfig和~/.cache/matplotlib中的文件,使matplotlib regenerate its fontList。

~/.cache/matplotlib/fontList.json文件提供了matplotlib所知道的所有字体的可读列表。在这里,您将发现如下条目:{<

更多推荐

python画图图例字体

本文发布于:2024-02-28 01:28:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1767451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:画图   图例   字体   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!