目录
问题
matplotlib默认无法支持中文,搜索了一下,参考这个issue和这篇文章,解决方法如下。
解决方法
下载字体
下载simhei.ttf。
定位matplotlib的ttf
import matplotlib
print(matplotlib.matplotlib_fname())
比如我的位置是venv/lib/python3.10/site-packages/matplotlib/mpl-data/matplotlibrc。
复制字体文件
cp simhei.ttf venv/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/
清除缓存
rm ~/.cache/matplotlib
使用字体
import matplotlib
matplotlib.rcParams['font.sans-serif'] = ['simhei']
matplotlib.rcParams['axes.unicode_minus'] = False
- 显示Disqus评论(需要科学上网)
FEATURED TAGS
        				
                            
                				
                                    人工智能
                                
                            
        				
                            
                				
                                    深度学习
                                
                            
        				
                            
        				
                            
        				
                            
                				
                                    chatbot
                                
                            
        				
                            
                				
                                    PyTorch
                                
                            
        				
                            
                				
                                    Java
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    BERT
                                
                            
        				
                            
        				
                            
        				
                            
                				
                                    git
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    编程
                                
                            
        				
                            
        				
                            
                				
                                    OCR
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    汪曾祺
                                
                            
        				
                            
                				
                                    语音识别
                                
                            
        				
                            
                				
                                    Kaldi
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    Linux
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    XLNet
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    情感分析
                                
                            
        				
                            
                				
                                    sentiment analysis
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    语法纠错
                                
                            
        				
                            
        				
                            
                				
                                    Transformer
                                
                            
        				
                            
                				
                                    Tensorflow
                                
                            
        				
                            
                				
                                    Huggingface
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    Ubuntu
                                
                            
        				
                            
        				
                            
                				
                                    TensorFlow
                                
                            
        				
                            
                				
                                    深度学习框架
                                
                            
        				
                            
                				
                                    Tensor2Tensor
                                
                            
        				
                            
                				
                                    机器翻译
                                
                            
        				
                            
                				
                                    微信
                                
                            
        				
                            
                				
                                    wechat
                                
                            
        				
                            
                				
                                    automation
                                
                            
        				
                            
                				
                                    selenium
                                
                            
        				
                            
                				
                                    webdriver
                                
                            
        				
                            
        				
                            
        				
                            
                				
                                    pywinauto
                                
                            
        				
                            
                				
                                    CentOS
                                
                            
        				
                            
        				
                            
                				
                                    GPU
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    Appium
                                
                            
        				
                            
                				
                                    t2t
                                
                            
        				
                            
                				
                                    代码阅读
                                
                            
        				
                            
                				
                                    中英翻译
                                
                            
        				
                            
                				
                                    公众号
                                
                            
        				
                            
                				
                                    爬虫
                                
                            
        				
                            
                				
                                    ocr
                                
                            
        				
                            
                				
                                    tesseract
                                
                            
        				
                            
                				
                                    pytesseract
                                
                            
        				
                            
                				
                                    python
                                
                            
        				
                            
                				
                                    默认参数
                                
                            
        				
                            
                				
                                    位置参数
                                
                            
        				
                            
        				
                            
                				
                                    VPN
                                
                            
        				
                            
        				
                            
                				
                                    JSON
                                
                            
        				
                            
                				
                                    Jackson
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    huggingface
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    RoPE
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    PagedAttention
                                
                            
        				
                            
                				
                                    vLLM
                                
                            
        				
                            
                				
                                    Pre-training
                                
                            
        				
                            
                				
                                    LLM
                                
                            
        				
                            
                				
                                    CPT
                                
                            
        				
                            
                				
                                    weather
                                
                            
        				
                            
                				
                                    forecasting
                                
                            
        				
                            
                				
                                    graph neural networks
                                
                            
        				
                            
                				
                                    qlora
                                
                            
        				
                            
                				
                                    quantization
                                
                            
        				
                            
                				
                                    transformers
                                
                            
        				
                            
        				
                            
                				
                                    cmake
                                
                            
        				
                            
                				
                                    pip
                                
                            
        				
                            
                				
                                    pipenv
                                
                            
        				
                            
                				
                                    conda
                                
                            
        				
                            
                				
                                    padding
                                
                            
        				
                            
                				
                                    vscode
                                
                            
        				
                            
        				
                            
                				
                                    debug
                                
                            
        				
                            
        				
                            
                				
                                    source code
                                
                            
        				
                            
                				
                                    build
                                
                            
        				
                            
        				
                            
                				
                                    deep learning
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    Speech
                                
                            
        				
                            
                				
                                    ASR
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    linux
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    pytorch
                                
                            
        				
                            
        				
                            
                				
                                    extension
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    Deep Learning
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    DeepSeek
                                
                            
        				
                            
                				
                                    Attention
                                
                            
        				
                            
        				
                            
                				
                                    MoE
                                
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
        				
                            
                				
                                    cs336
                                
                            
        				
                            
                				
                                    bpe tokenizer