美文网首页数据可视化
matplotlib.pyplot基本用法

matplotlib.pyplot基本用法

作者: wildsre | 来源:发表于2016-09-28 15:11 被阅读4644次

参考:
官网文档
3d标注
legend

  • 查看matplot配置文件:
import matplotlib
print(matplotlib.matplotlib_fname())
from pylab import *
zhfont = mpl.font_manager.FontProperties(fname='/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc')

window 下
https://my.oschina.net/u/1180306/blog/279818

单个图像

  • plt.figure(figsize=(w, h)) #创建对象,并指定宽度w高度h,默认像素为80ppi,单位为100像素?还是英寸?

  • plt.plot([1,2,3,4], [1,4,9,16], 'ro') #指定xy坐标,显示样式

  • plt.axis([0, 6, 0, 20]) #指定横纵轴 [xmin, xmax, ymin, ymax]

  • plt.xlabel('Smarts')plt.ylabel('Probability') #设置 x 轴和 y 轴的文字

  • plt.title('Histogram of IQ')

  • 设置文字注释: plt.text(60, .025, r'$\mu=100,\ \sigma=15$')

  • 不显示坐标轴: plt.axis('off')

  • 显示图像: plt.show()

  • 保存图像: fig.saveimg(imgname)

多幅图中多个图像

  • plt.xx操作是针对当前fig对象,通过plt.figure(str)切换到需要操作的图像,通过plt.subplot(num)切换到子图像

subplot(236): 图像总数为2行x3列,中的第6幅图


23x
import matplotlib.pyplot as plt
plt.figure(1) # the first figure,也可以为字符串
plt.subplot(211) # the first subplot in the first figure
plt.plot([1, 2, 3])
plt.subplot(212) # the second subplot in the first figure
plt.plot([4, 5, 6])
plt.figure(2) # a second figure
plt.plot([4, 5, 6]) # creates a subplot(111) by default
plt.figure(1) # figure 1 current; subplot(212) still current
plt.subplot(211) # make subplot(211) in figure1 current
plt.title('Easy as 1, 2, 3') # subplot 211 title
  • 多幅子图:
fig=plt.figure()
ax1=fig.add_subplot(311)
  • 设置横坐标为[0, 100]
    ax1.set_xlim(0,100)
  • 设置x轴标签
    ax1.set_xlabel('x')
  • 设置子图之间的距离
    调整子图的横向和纵向间隔
    fig.subplots_adjust(wspace=0.5, hspace=0.3)
    关于共享横轴和总轴

相关文章

  • python PDF到画直方图

    一、最基本用法示例 import numpy as np import matplotlib.pyplot as ...

  • matplotlib.pyplot基本用法

    参考:官网文档3d标注legend 查看matplot配置文件: 点形线形:matplotlib.pyplot.p...

  • 学会展示数据(Matplotlib)

    基本使用 1.1 基本用法 使用import导入模块matplotlib.pyplot,并简写成plt使用impo...

  • python 画图基本命令

    #画图的基本命令import matplotlib.pyplot as pltimport numpy as np...

  • matplotlib.pyplot中subplots()的用法

    在数据分析过程中,我们经常需要将数据可视化。这个过程中,人们经常会使用到 subplots 这个函数。今天我们就来...

  • 定时器

    setTimeout和clearTimeout基本用法 setInterval和clearInterval基本用法...

  • 2019-11-16

    E战到底DAY14 SUMIF和SUMIFS函数 一.基本用法 SUMIF基本用法 SUMIFS基本用法 SUMI...

  • 11 - 动态数据绑定实现原理

    一、defineProperty 基本用法 1、基本写法: 2、参数 3、descriptor 参数的基本用法 1...

  • as 基本用法

    插件安装 plugin auto import 相当于 eclipse ctrl+o 或者as alt+enter...

  • 基本用法

    Installation 安装 npm install vue vue-server-renderer --sav...

网友评论

    本文标题:matplotlib.pyplot基本用法

    本文链接:https://www.haomeiwen.com/subject/ltbhyttx.html