Python matplotlib 统计图遇见的问题

1、问题:
ValueError: Format 'jpg' is not supported (supported formats: eps, pdf, pgf, png, ps, raw, rg
解决:
python -m pip install pillow

2、matplotlib中文乱码问题参见: matplotlib 图例中文乱码

3、问题:
ValueError: 'explode' must be of length 'x'
解决方法:
不添加 explode 参数试试

4、WordCloud 中文乱码:
解决方法:
百度下载保存字体 simhei.ttf ,然后修改 font_path

default_font = 'C:\\Python37\\SimHei.ttf'  # 生成词云用的默认字体
wc = WordCloud(font_path=default_font,background_color='white',margin=2,
                    max_font_size=250,width=2000,height=2000,
                    min_font_size=30,max_words=2000)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容