seaborn(matplotlib)画图,linux系统中文乱码等问题解决
data = pd.read_json(json.dumps(issue_dpl))
# set pic size
plt.figure(figsize=(13, 5))
sns.set_style('whitegrid', {'font.sans-serif': ['simhei', 'Arial']})
ax3 = sns.barplot(x=data['cls'], y=data['count'], data=data, ci=0)
ax3.set_title(u'问题分类统计')
ax3.set_xlabel(u'')
ax3.set_ylabel(u'')
plt.xticks(np.arange(len(cls_arr)) + 0.4 / 2, cls_arr, rotation=45)
sio = StringIO.StringIO()
savefig(sio, bbox_inches='tight', format='png')
savefig(‘test.png’, bbox_inches='tight', format='png') # tight强制显示全部,避免字体显示不全
plt.show()
cls count
0 不良质量 44
1 不正确校验 39
2 安全配置 32
3 信息泄露 24
4 权限控制 23
参考地址:https://www.cnblogs.com/gczr/p/6767175.html
https://blog.csdn.net/qq_34264472/article/details/53814653
linux Tkinter导入报以下错解决:
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>>
KeyboardInterrupt
>>>
先看原版本python是否可以导入,如果可以的话,直接跳过安装tk等包,否则先后安装tk-devel,python-tk, tcl, tcl-devel等包,然后重新编译安装python,解决
linux系统画图报错解决:(TclError: no display name and no $DISPLAY environment variable)
参考:https://blog.csdn.net/qq_22194315/article/details/77984423
linux中文乱码解决:
- 到 anaconda 的 matplotlib 中查看是否有 simhei.ttf 字体:
cd ~/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/fonts/ttf
ls -al | grep simhei
- 如果没有,从 windows 中用 everything 搜索全局文件,找到 simhei.ttf,并将其上传到linux 的 matplotlib 的 fonts/ttf 文件夹
- 修改配置文件~/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc 文件,
-
font.family : sans-serif
font.sans-serif : simhei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
-
- (linux)删除~/.cache/matplotlib/目录下的 fonts cache list,
rm -r ~/.cache/matplotlib
- 代码设置 matplotlib 和 seaborn 的环境
-
import matplotlib as mpl
# mpl.rcParams['font.sans-serif'] = ['simhei']
# mpl.rcParams['font.serif'] = ['simhei']
import seaborn as sns
sns.set_style("darkgrid",{"font.sans-serif":['simhei','Droid Sans Fallback']})
-
将该文件拷贝到.cache/matplotlib 目录下,并找到以下两行,改为如下:
- https://github.com/mwaskom/seaborn/issues/1009
- http://www.th7.cn/Program/Python/201704/1156781.shtml
- https://www.jianshu.com/p/b76481530472
seaborn(matplotlib)画图,linux系统中文乱码等问题解决的更多相关文章
- Linux oracle中文乱码的问题解决
乱码问题的根源是字符集的修改 1.查看linux的默认语言 2.查看客户端的语言编码设置 配置文件中的配置: cat ~/.bash_profile 注意修改配置信息: export PATHexp ...
- 本地文件程序脚本上传linux系统中文乱码问题
# 使用notepad++ 编辑器打开,转换一下格式保存,然后上传即可
- 解决Ubuntu系统中文乱码显示问题,终端打开文件及查看目录
解决Ubuntu系统中文乱码显示问题 [日期:2014-02-20] 来源:Linux社区 作者:njchenyi [字体:大 中 小] 我是先安装了Ubuntu 12.04 Server,然后 ...
- Linux系统中文显示
# Linux系统中文显示 ### 配置文件路径------------------------------ 路径`/etc/locate.conf` ### 查看系统当前字符集----------- ...
- Linux改中文乱码显示
Linux改中文乱码显示 可以使用locale命令,查看当前系统默认采用的字符集# locale在RedHat/CentOS系统下,记录系统默认使用语言的文件是/etc/ ...
- Linux下中文乱码
Linux下中文乱码 修改mysql配置文件,centeros下 配置文件在 /etc/my.cnf vi /etc/my.cnf 在[mysqld]段下添加 character-set-server ...
- Xshell4连接,Linux系统中文显示乱码解决办法
Xshell 是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Microsoft Windows 平台的TELNET NetSarang Xshell 4 Build 0120议.使用 ...
- linux之添加切换用户、系统变量、selinux、防火墙、系统中文乱码的讲解
######linux用户分类1.root 用户 linux皇帝 2.普通用户 贫民百姓 [root@oldboyedu-01 oldboy]# useradd oldboy[root@oldboye ...
- Python画图matplotlib展示图中中文乱码
在用python的 matplotlib 画图的时候,在图表上面有中文乱码问题,如下的: 解决过程: 平台:windows,python2.7步骤一:打开设置文件 import matplotlib ...
随机推荐
- svn的外网设置访问方法
一.花生壳 1. 设置静态ip 选择 DHCP服务器 -> 静态地址分配,为内网内的机器分配静态ip 2.设置端口转发 选择 转发规则 -> 虚拟服务器,将外网对443端口的访问转发到安装 ...
- C++语言基础(16)-string类
使用 string 类需要包含头文件<string>,下面的例子介绍了几种定义 string 变量(对象)的方法: #include <iostream> #include & ...
- 详解TCP建立连接全过程
TCP是因特网中的传输层协议,使用三次握手协议建立连接,下面是TCP建立连接的全过程. 上图画出了TCP建立连接的过程.假定主机A是TCP客户端,B是服务端.最初两端的TCP进程都处于CLOSED状态 ...
- poj 3666 河南省第七届程序设计D题(山区修路)
题目大意: 给定一个序列,以最小代价将其变成单调不增或单调不减序列,求最小的变动价值:需要用到离散化dp 状态转移方程: dp[i][j]=abs(j-w[i])+min(dp[i-1][k]);(k ...
- out传值
public void Out(out int a, out int b) {//out相当于return返回值 //可以返回多个值 //拿过 ...
- objc_setAssociatedObject 使用(转)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ...
- SpringMVC请求使用@PathVariable获取文件名称并且文件名中存在.导致路径被截取的问题
在SpringMVC中,当使用@pathVariable通过Get请求获取路径名称时,如果路径名称上存在小数点,则获取不到小数点后面的内容,会被Spring截取. 比如我获取某一文件,路径是local ...
- ToString(string format)输出格式简述
ToString说明 ToString 是 .NET Framework 中主要的格式化方法.它将对象转换为其字符串表现形式,使它适合于显示.(有关对 .NET Framework 中的格式设置支持的 ...
- int abs(int number)函数有感: 求补码和通过补码求对应的整数 C++(增加:数字的二进制表示中1的个数)
#include "limits.h" #include "math.h" int abs(int number) { int const mask = num ...
- hdu3208 Power of Integer
/** 题目:H - Power of Integer 链接:https://vjudge.net/contest/152887#problem/H 题意:给出区间[a, b],问你区间[a, b]所 ...