今天看啥  ›  专栏  ›  Alyna_C

【基础】学习笔记38-Python3 matplotlib绘图-2

Alyna_C  · 简书  ·  · 2020-12-15 00:04

绘制2D图

折线图plot

散点图scatter

柱形图bar

基本绘制:bar的参数设置、设置颜色、描边、设置填充、设置刻度标签

堆叠柱状图:柱状图坐标从默认bottom、left设定到top、ri

条形图barh

饼图pie

面积图(堆积折线图) stackplot

雷达图plot

<开启角度图,设置角度标签>

箱线图boxplot

环形图pie

<设置wadgeprops={width=0.3,edgecolor='w'}饼弧宽度和边框颜色>

等高线 contour/contour<三维数,cmap设定颜色>

词云图imshow<第三方库:jieba、wordcloud/stylecloud>


热力图imshow/seaborn<第三方库seaborn>

1.用plt.imshow函数绘制热力图

imshow(X, cmap=None, norm=None, aspect=None, interpolation=None,alpha=None, vmin=None, vmax=None, origin=None, extent=None, shape=None,filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, hold=None,data=None, **kwargs)

X为数组,数组矩阵重构,可使用reshape函数

2.使用第三方库seaborn.heatmap绘制热力图

seaborn.heatmap(data,vmin=None, vmax=None, cmap=None, center=None, robust=False, annot=None,fmt='.2g', annotkws=None, linewidths=0, linecolor='white', cbar=True,cbarkws=None, cbar_ax=None, square=False, ax=None, xticklabels=True, yticklabels=True,mask=None, **kwargs)

3.imshow()与seeborn.heatmap的区别:

——seeborn.heatmap能直接把颜色调出来,cbar=False取消颜色棒的显示,默认为True

plt.imshow()需要另外调用一个函数plt.colorbar()。其中plt.colorbar() 参数shrink的值为bar的压缩尺寸,默认为1

——seaborn.heatmap能在图表显示数据,参数annot=True



难点

在同一坐标轴中画不同类型的图,设置坐标轴的格式

绘制不同坐标系的图形

绘制标定线

从文件获取数据---清洗数据

图表figure对象和坐标Axes的使用区别

从外部文件提取数据,如txt、excel等

从网络抓取数据

绘制2D图:K线图、仪表盘、

绘制3D图



扩展阅读

Matplotlib 中文用户指南

<matplotlib的用户指南分为三个等级:入门,中级,高级>




原文地址:访问原文地址
快照地址: 访问文章快照