首页 > 编程知识 正文

一元二次的函数的性质,一元二次方程是函数吗

时间:2023-05-06 18:51:51 阅读:261018 作者:1527

matplotlib 基础练习:画一元二次函数

样例:
1、安装matplotlib模块
Matplotlib 是 Python 的绘图库。
安装方法:
pip install matplotlib -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

C:UsersAshley>pip install matplotlib -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cnDEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.Looking in indexes: http://pypi.tuna.tsinghua.edu.cn/simpleCollecting matplotlib Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c9/1e/0cf26e92de5438d0f2118435476665aae843002f4701da296b0b3252a237/matplotlib-3.0.3-cp35-cp35m-win_amd64.whl (9.1 MB) |████████████████████████████████| 9.1 MB 6.8 MB/sRequirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in d:lenovosoftstorepython35libsite-packages (from matplotlib) (2.2.0)Requirement already satisfied: python-dateutil>=2.1 in d:lenovosoftstorepython35libsite-packages (from matplotlib) (2.6.0)Collecting kiwisolver>=1.0.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e8/27/74677003aecfc85421f6b70db3e49b52e65f6497a5f2faf4e345588b3c61/kiwisolver-1.1.0-cp35-none-win_amd64.whl (57 kB) |████████████████████████████████| 57 kB 231 kB/sRequirement already satisfied: numpy>=1.10.0 in d:lenovosoftstorepython35libsite-packages (from matplotlib) (1.14.2)Collecting cycler>=0.10 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)Requirement already satisfied: six>=1.5 in d:lenovosoftstorepython35libsite-packages (from python-dateutil>=2.1->matplotlib) (1.11.0)Requirement already satisfied: setuptools in d:lenovosoftstorepython35libsite-packages (from kiwisolver>=1.0.1->matplotlib) (39.0.1)Installing collected packages: kiwisolver, cycler, matplotlibSuccessfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.0.3

2、调用matplotlib模块实现 画一元二次函数

numpy模块 NumPy(Numerical Python) 是 Python
语言的一个扩展程序库,支持大量的维度数组与矩阵运算,此外也针对数组运算提供大量的数学函数库。linspace函数 linspace(x1,x2,N)
linspace是Matlab中的均分计算指令,用于产生x1,x2之间的N点行线性的矢量。

代码:

import matplotlib.pyplot as plt # 导入matplotlib包的子模块pyplot,并将其重命名为pltimport numpy as np # 导入numpy,并将其重命名为npx = np.linspace(-5, 5, 101) # 生成-5到5之间的51个点的一维元组print(x)y = 2 * x * x + 1plt.plot(x, y) # 画图plt.show()plt.savefig(r"D:u_careeri_coderi_python_course_1026figure.jpg") # 保存到本地

参考链接:
NumPy Matplotlib
python 画正弦曲线
python之numpy的基本使用
NumPy 教程
linspace

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。