Template
Finished Homework2.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
'''
|
||||
Author: SJ2050
|
||||
Date: 2021-10-29 19:51:52
|
||||
LastEditTime: 2021-10-29 19:55:28
|
||||
Version: v0.0.1
|
||||
Description: Solution for homework2.2.
|
||||
Copyright © 2021 SJ2050
|
||||
'''
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
if __name__ == '__main__':
|
||||
y_func = lambda x: np.sin(x-2)**2*np.exp(-x**2)
|
||||
xs = np.linspace(0, 2)
|
||||
ys = np.array([y_func(x) for x in xs])
|
||||
plt.plot(xs, ys, color='blue')
|
||||
plt.xlabel('x label')
|
||||
plt.ylabel('y label')
|
||||
plt.title('$sin^2(x-2)e^{-x^2}$')
|
||||
plt.show()
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,12 @@
|
||||
# 2.2 绘制函数并画出标题以及x, y轴
|
||||
|
||||
## (1). 解题思路
|
||||
|
||||
绘制函数可以直接调用`matplotlib.pyplot`画出,而标题以及x, y轴可以通过设置`pyplot`对象中的`title`以及`xlabel`与`ylabel`属性进行绘制,它们支持`Latex`语法。
|
||||
|
||||
|
||||
|
||||
## (2). 运行结果
|
||||
|
||||

|
||||
|
||||
Reference in New Issue
Block a user