【环境配置】Windows环境下 Pandas绘图 中文乱码 解决方法

其实绘图的话可以去用pyecharts,好用的一笔

1. 找到配置文件

本人的配置文件在:

C:\ProgramData\Anaconda3\pkgs\matplotlib-2.1.2-py36h016c42a_0\Lib\site-packages\matplotlib\mpl-data\matplotlibrc

可以搜索matplotlibrc,直接定位到这个文件。

2. 修改配置文件

  • 在200行左右,找到 font.family这行:
#font.family         : sans-serif
#font.style          : normal
#font.variant        : normal
#font.weight         : medium
#font.stretch        : normal
# note that font.size controls default text sizes.  To configure
# special text sizes tick labels, axes, labels, title, etc, see the rc
# settings for axes and ticks. Special text sizes can be defined
# relative to font.size, using the following values: xx-small, x-small,
# small, medium, large, x-large, xx-large, larger, or smaller
#font.size           : 10.0
#font.serif          : DejaVu Serif, Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
#font.sans-serif     : DejaVu Sans, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
#font.cursive        : Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, cursive
#font.fantasy        : Comic Sans MS, Chicago, Charcoal, Impact, Western, Humor Sans, xkcd, fantasy
#font.monospace      : DejaVu Sans Mono, Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
  • 将这三行注释取消,并在第二行和第三行的冒号后面分别加上SimHei
font.family         : sans-serif
font.serif          : SimHei, DejaVu Serif, Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
font.sans-serif     : SimHei, DejaVu Sans, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

3. 完成

重启jupyter,完成。

你可能感兴趣的:(数据可视化,pandas,matplotlib,中文乱码,绘图,数据可视化)