2020高考数学 理科一卷 导数题
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
# 画任意函数的图像
# 指定函数表达式
def function(x):
return (x + 0.5 * np.power(x, 3) + 1 - np.power(np.e, x))/(x**2)
# 生成 data y
def generate_y_from_x(*args):
y = [function(i) for i in args]
return y
# 画函数图像, 区间为 [left, right)
def plot_function(left, right):
np_x = np.arange(left, right, 0.01)
list_x = np_x.tolist()
y = generate_y_from_x(*list_x)
plt.figure(1) # 创建画板1
plt.subplot(111) # 进入111区域
plt.plot(list_x, y, 'g', linewidth=2.5)
#设置坐标轴名称
plt.xlabel('x')
plt.ylabel('y')
plt.title('function') # 指定111区域的图的标题
plt.axis('equal') # 指定111区域的 x, y比例为一比一
plt.grid() # 111区域画格子
plt.show()