zoukankan      html  css  js  c++  java
  • matplotlib

    1.matplotlib-数据可视化和绘图

    2.导入方式

    1 import matplotlib.pyplot as plt#第一种导入方式
    2 from matplotlib import pyplot as plt#第二种导入方式

    3.功能

    使用默认属性的简单plot

    1 plt.plot(x,y)
    2 plt.show

    修改绘图属性

     1 # Imports
     2 import numpy as np
     3 import matplotlib.pyplot as plt
     4 
     5 # Create a new figure of size 8x6 points, using 100 dots per inch
     6 plt.figure(figsize=(8,6), dpi=80)
     7 
     8 # Create a new subplot from a grid of 1x1
     9 plt.subplot(111)
    10 
    11 X = np.linspace(-np.pi, np.pi, 256,endpoint=True)
    12 C,S = np.cos(X), np.sin(X)
    13 
    14 # Plot cosine using blue color with a continuous line of width 1 (pixels)
    15 plt.plot(X, C, color="blue", linewidth=1.0, linestyle="-")
    16 
    17 # Plot sine using green color with a continuous line of width 1 (pixels)
    18 plt.plot(X, S, color="green", linewidth=1.0, linestyle="-")
    19 
    20 # Set x limits
    21 plt.xlim(-4.0,4.0)
    22 
    23 # Set x ticks
    24 plt.xticks(np.linspace(-4,4,9,endpoint=True))
    25 
    26 # Set y limits
    27 plt.ylim(-1.0,1.0)
    28 
    29 # Set y ticks
    30 plt.yticks(np.linspace(-1,1,5,endpoint=True))
    31 
    32 # Save figure using 72 dots per inch
    33 # savefig("../figures/exercice_2.png",dpi=72)
    34 
    35 # Show result on screen
    36 plt.show()
    View Code

     添加图例

    1 plt.plot(x,c,label='cosine')
    2 plt.plot(x,s,label='sine')
    3 plt.legend(loc='upper left',frameon=False)

    matplotlib.pyplot.plot(*args, **kwargs)

  • 相关阅读:
    haslayout详解
    linux定时任务-cron
    linux安装SVN
    linux java配置
    KVM virsh常用命令篇
    KVM创建虚拟机
    KVM和远程管理工具virt-manager
    mysql 基础命令
    json在线工具
    mvn简单命令
  • 原文地址:https://www.cnblogs.com/Pygoupfs/p/9241708.html
Copyright © 2011-2022 走看看