findfont: Font family 'Times New Roman' not found.
这是因为在python环境中的matplotlib文件夹下没有这个字体的文件。
对于windows系统,请参考:https://blog.csdn.net/qq_49323609/article/details/139026798
Macos系统:
- 先打开软件:
- 找到字体的路径
- 然后模仿以上https://blog.csdn.net/qq_49323609/article/details/139026798链接中的路径,找到类似于"/home/user/anaconda3/envs/pytorch/lib/python3.9/site-packages/matplotlib/mpl-data/fonts/ttf"的文件夹,直接将文件复制过去。
- 最后需要将matplotlib的字体缓存删除:rm -r ~/.cache/matplotlib/
Ubuntu系统:
同样地操作,可以将本地系统中的.ttf文件上传到对应的/matplotlib/mpl-data/fonts/ttf文件夹下。如果是macos系统,可以使用scp 本地文件路径 服务器用户名@ip:服务器对应地址。需要注意的是,对于Times New Roman本地路径,这个Times New Roman.ttf文件带有空格,会找不到,可以使用转义字符Times\ New\ Roman