python:绘制一元四次函数的曲线

编写  test_x4_x2_4x.py  如下

# -*- coding: utf-8 -*-
""" 绘制函数 y = x^4+x^2+4x-3 在 -2<=x<=2 的曲线 """
import numpy as np
from matplotlib import pyplot as plt

# 用于正常显示中文标题,负号
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

x = np.arange(-2., 2., 0.01)
y = np.power(x,4) +x**2 +4*x -3

# 可视化
fig = plt.figure()
axes = fig.add_subplot(111)
axes.plot(x, y) # 画曲线
#axes.axis('scaled') # 用缩尺制图
axes.axis('equal')
plt.title('函数 y = x^4+x^2+4x-3 的曲线')
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.show()

运行 python test_x4_x2_4x.py 

相关推荐

  1. python基础知识(列表、组、函数

    2024-07-15 05:30:03       27 阅读
  2. OPenCV中绘制多条多边形曲线函数polylines使用

    2024-07-15 05:30:03       34 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-15 05:30:03       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-15 05:30:03       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-15 05:30:03       58 阅读
  4. Python语言-面向对象

    2024-07-15 05:30:03       69 阅读

热门阅读

  1. SpringBoot+Vue实现简单的文件上传(策略模式)

    2024-07-15 05:30:03       25 阅读
  2. Zookeeper背景优缺点,以及应用场景

    2024-07-15 05:30:03       26 阅读
  3. Linux/C++:Json--网络编程中的奇妙小工具

    2024-07-15 05:30:03       30 阅读