matplotlib 库的使用
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 库的使用的更多相关文章
- 在Ubuntu 14.04 64bit上安装numpy和matplotlib库
原文:http://blog.csdn.net/tao_627/article/details/44004541 按照这个成功安装! 机器学习是数据挖掘的一种实现形式,在学习<机器学习实战> ...
- 数据分析与展示——Matplotlib库入门
Matplotlib库入门 Matplotlib库介绍 Matliotlib库是Python优秀的数据可视化第三方库. Matliotlib库的效果见:http://matplotlib.org/ga ...
- matplotlib库的简单应用
matplotlib库 import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['font.family']='Si ...
- 对matplotlib库的运用
1.matplotlib库的运用效果图 绘制基本的三角函数 ...
- 第二周 数据分析之展示 Matplotlib库入门
Matplotlib库介绍:优秀的数据可视化第三方库 使用:Matplotlib库由各种可视化类构成,内部结构复杂,受Matlab启发,matplotlib.pyplot是绘制各类可视化图形的命令子库 ...
- numpy, matplotlib库学习笔记
Numpy库学习笔记: 1.array() 创建数组或者转化数组 例如,把列表转化为数组 >>>Np.array([1,2,3,4,5]) Array([1,2,3,4,5]) ...
- 利用matplotlib库和numpy库画数学图形
首先,电脑要安装到matplotlib库和numpy库,这可以通过到命令符那里输入“pip install matplotlib ”,两个操作一样 其次,参照下列代码: import numpy as ...
- Python的Matplotlib库简述
Matplotlib 库是 python 的数据可视化库import matplotlib.pyplot as plt 1.字符串转化为日期 unrate = pd.read_csv("un ...
- Python3.x(windows系统)安装matplotlib库
Python3.x(windows系统)安装matplotlib库 cmd命令: pip install matplotlib 执行结果:
- 机器学习 Matplotlib库入门
2017-07-21 15:22:05 Matplotlib库是一个优秀的python的数据可视化的第三方类库,其中的pyplot支持了类似matlab的图像输出操作.matplotlib.pyplo ...
随机推荐
- httpclient信任所有证书解决SSLException:Unrecognized SSL message,plaintext connection
在使用 HttpClient 工具调用第三方 Http 接口时报错 javax.net.ssl.SSLException:Unrecognized SSL message,plaintext conn ...
- 模块购物商城和ATM机代码:
http://outofmemory.cn/python/video/let-us-python/ python为程序员服务 快来加入群[python爬虫交流群](群号570070796),发现精彩 ...
- BME200加密网关,在电力与工业应用的加密网关设计与介绍
加密通信网关,顾名思义就是带加密的通信网关终端, 一般业内主是需用到是工业通信关行业的为主的.,BME200加密通信网关,主要电力和工业互联网相关领域开发的一款加密通信网关. 为什么出现加密网关 1 ...
- win10去除快捷方式小箭头
切忌删除注册表项: HKEY_CLASSES_ROOT -> lnkfile -> IsShortcut 这个方法以前是可以的,但是在2018年之后更新的系统就会出现任务栏图标打不开的情况 ...
- java基础学习_io流之FileInputStream
一.FileInputStream属性: /* File Descriptor - handle to the open file */private final FileDescriptor fd; ...
- Resource 使用详解
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以 ...
- win系统上Anaconda国内镜像配置
清华镜像2019.6.15已恢复 中科大镜像2019.7.1停机维护后恢复 1.打开anaconda prompt 2.添加清华镜像1:https://mirrors.tuna.tsinghua.ed ...
- 【简洁易懂】CF372C Watching Fireworks is Fun dp + 单调队列优化 dp优化 ACM codeforces
题目大意 一条街道有$n$个区域. 从左到右编号为$1$到$n$. 相邻区域之间的距离为$1$. 在节日期间,有$m$次烟花要燃放. 第$i$次烟花燃放区域为$a_i$ ,幸福属性为$b_i$,时间为 ...
- java并发编程(二十四)----(JUC集合)ArrayBlockingQueue和LinkedBlockingQueue介绍
这一节我们来了解阻塞队列(BlockingQueue),BlockingQueue接口定义了一种阻塞的FIFO queue,每一个BlockingQueue都有一个容量,当容量满时往BlockingQ ...
- (二十五)c#Winform自定义控件-有确定取消的窗体(一)
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...