1.问题描述:

在学习kaggle经典学习项目Titanic,进行数据可视化处理时,对于每个特征进行相关性分析(也就是绘制pearson correlation heatmap )热力相关性矩阵时, plt.show() 图形绘制出来,字体会重叠.导致无法观察

# Visualisations
"""将数据进行可视化"""
print(train.head(3))
# correlation heatmap 相关性热点矩阵 plt.figure(figsize=(14,12))
plt.title('Pearson Correlation of Features',y=1.05,size=15)
sns.heatmap(train.astype(float).corr(),linewidths=0.1,vmax=1.0,
square=True,linecolor='white',annot=True)
plt.show()

导致看不清坐标轴每个特征的含义

2.解决问题:

思路:只要找到plt所含有的命令,将X.Y坐标轴字体进行旋转即可

寻找python xlabel 的文档

Help on function xlabel in module matplotlib.pyplot:

xlabel(s, *args, **kwargs)
Set the *x* axis label of the current axis. Default override is:: override = {
'fontsize' : 'small',
'verticalalignment' : 'top',
'horizontalalignment' : 'center'
} .. seealso:: :func:`~matplotlib.pyplot.text`
For information on how override and the optional args work

发现没有关于xlabel进行旋转的参数,

寻找 python xticks 文档

Help on function xticks in module matplotlib.pyplot:

xticks(*args, **kwargs)
Get or set the *x*-limits of the current tick locations and labels. :: # return locs, labels where locs is an array of tick locations and
# labels is an array of tick labels.
locs, labels = xticks() # set the locations of the xticks
xticks( arange(6) ) # set the locations and labels of the xticks
xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') ) The keyword args, if any, are :class:`~matplotlib.text.Text`
properties. For example, to rotate long labels:: xticks( arange(12), calendar.month_name[1:13], rotation=17 )

上面黑体下划线,rotate long label

找到参数 rotation

plt.figure(figsize=(14,12))
plt.title('Pearson Correlation of Features',y=1.05,size=15)
sns.heatmap(train.astype(float).corr(),linewidths=0.1,vmax=1.0,
square=True,linecolor='white',annot=True)
plt.xticks(rotation=90) # 将字体进行旋转
plt.yticks(rotation=360)
plt.show()

标签旋转,可清晰看到每个特征的含义

问题思考:

就是plt.show() 输出不了中文字体,这个问题还没有解决

matplotlib 库的使用的更多相关文章

  1. 在Ubuntu 14.04 64bit上安装numpy和matplotlib库

    原文:http://blog.csdn.net/tao_627/article/details/44004541 按照这个成功安装! 机器学习是数据挖掘的一种实现形式,在学习<机器学习实战> ...

  2. 数据分析与展示——Matplotlib库入门

    Matplotlib库入门 Matplotlib库介绍 Matliotlib库是Python优秀的数据可视化第三方库. Matliotlib库的效果见:http://matplotlib.org/ga ...

  3. matplotlib库的简单应用

    matplotlib库 import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['font.family']='Si ...

  4. 对matplotlib库的运用

    1.matplotlib库的运用效果图 绘制基本的三角函数                                                                        ...

  5. 第二周 数据分析之展示 Matplotlib库入门

    Matplotlib库介绍:优秀的数据可视化第三方库 使用:Matplotlib库由各种可视化类构成,内部结构复杂,受Matlab启发,matplotlib.pyplot是绘制各类可视化图形的命令子库 ...

  6. numpy, matplotlib库学习笔记

    Numpy库学习笔记: 1.array()   创建数组或者转化数组 例如,把列表转化为数组 >>>Np.array([1,2,3,4,5]) Array([1,2,3,4,5]) ...

  7. 利用matplotlib库和numpy库画数学图形

    首先,电脑要安装到matplotlib库和numpy库,这可以通过到命令符那里输入“pip install matplotlib ”,两个操作一样 其次,参照下列代码: import numpy as ...

  8. Python的Matplotlib库简述

    Matplotlib 库是 python 的数据可视化库import matplotlib.pyplot as plt 1.字符串转化为日期 unrate = pd.read_csv("un ...

  9. Python3.x(windows系统)安装matplotlib库

    Python3.x(windows系统)安装matplotlib库 cmd命令: pip install matplotlib 执行结果:

  10. 机器学习 Matplotlib库入门

    2017-07-21 15:22:05 Matplotlib库是一个优秀的python的数据可视化的第三方类库,其中的pyplot支持了类似matlab的图像输出操作.matplotlib.pyplo ...

随机推荐

  1. python每个文件都需要顶部注释,那今天介绍一个方法,只需要设置一次,下次新建python文件后,注释自动出现在顶部的方法

    python每个文件都需要顶部注释,那今天介绍一个方法,只需要设置一次,下次新建python文件后,注释自动出现在顶部的方法 只需要在file -----settings------file and ...

  2. maven-build-downloading

    1. 场景描述 maven库用的是公司私服和阿里云结合的方式(maven多仓库配置),本项目maven依赖的有其他项目组的jar包(单点登录),但是天有不测风云,依赖单点登录的好几个jar包,在编译( ...

  3. jenkins弱口令漏洞

    jenkins弱口令漏洞 一.漏洞描述 通过暴力破解管理控制台,如果爆破成功,可获得后台管理权限.操作后台,后台可通过脚本命令行功能执行系统命令,如反弹shell等,低权限可以通过创建控制台输出方式执 ...

  4. 图解Redis之数据结构篇——压缩列表

    前言     同整数集合一样压缩列表也不是基础数据结构,而是 Redis 自己设计的一种数据存储结构.它有点儿类似数组,通过一片连续的内存空间,来存储数据.不过,它跟数组不同的一点是,它允许存储的数据 ...

  5. SpringMVC项目案例之---数据的获取与显示

    数据的获取与显示 (一)功能 1.对用户输入的数据进行获取 2.将获取的数据显示到页面 3.使用了SpringMVC技术的注解方式 4.使用了过滤器,处理中文乱码问题 5.在web.xml中设置了访问 ...

  6. 基于http(s)协议的模板化爬虫设计

    声明:本文为原创,转载请注明出处 本文总共三章,前面两章废话吐槽比较多,想看结果的话,直接看第三章(后续会更新,最近忙着毕设呢,毕设也是我自己做的,关于射频卡的,有时间我也放上来,哈哈). 一,系统总 ...

  7. JVM实战---类加载的过程

    任何程序都需要加载到内存才能与CPU进行交流 同理, 字节码.class文件同样需要加载到内存中,才可以实例化类 ClassLoader的使命就是提前加载.class 类文件到内存中 在加载类时,使用 ...

  8. 提取html内的文字1

    public static string StripHTML(string strHtml)   {    string [] aryReg ={           @"<scrip ...

  9. Xcodebuild命令使用

    Xcodebuild简介 Xcodebuild是命令行工具包的其中一项. 命令行工具包(Command Line Tools)是一个轻量的.可以与XCode分开的.在Mac上单独下载的命令行工具包. ...

  10. Yii CGridView 之 SQL 语句

    在CGridView里,有时候需要用到复杂的查询时,可用 CSqlDataProvider替换CActiveDataProvider, CSqlDataProvider 可用复杂的查询语句,例子如下: ...