zoukankan      html  css  js  c++  java
  • Python matplot的使用(一)

    其实,使用它的直接原因是因为matlab太大了,不方便。另外,就是它是免费的。

    在安装这个库的时候,会需要安装一些它所依赖的库,比如six等。从sourceforge上下载,只需按照提示安装完成就行了。

    下边是第一个matplot的绘图实例,其中,数学方便的东西主要用到了numpy的东西。 很简单! 跟matlab太像了~~

     1 import numpy as np
     2 import matplotlib.pyplot as plt
     3 
     4 x = np.linspace(0, 10, 1000)    #1000 points
     5 y = np.sin(x)
     6 z = np.cos(x**2)
     7 
     8 plt.figure(figsize=(8,4))
     9 plt.plot(x,y,label="$sin(x)$",color="red",linewidth=2)
    10 plt.plot(x,z,"g--",label="$cos(x^2)$",linewidth=1.5)
    11 plt.xlabel("Time(s)")
    12 plt.ylabel("Value")
    13 plt.title("My first example")
    14 plt.ylim(-1.5,1.5)
    15 plt.legend()
    16 plt.show()
    View Code

    运行结果如下:

  • 相关阅读:
    linux常用命令中篇
    htaccess正则规则学习笔记整理
    个性签名
    求函数的单调区间
    函数的奇偶性
    函数的对称性
    函数的周期性
    复合函数
    赋值法
    高中数学中高频变形技巧收录
  • 原文地址:https://www.cnblogs.com/AmitX-moten/p/4170830.html
Copyright © 2011-2022 走看看