python 绘制函数曲线

2018-06-27 21:08:16 天之饺子整理 绘制曲线求函数 绘制曲线求函数

Q1:求助python绘制三维曲线

直接用matplotlib模块相对来说非常简单。

from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
x = np.linspace(0, 1, 100)
y = np.sin(x * 2 * np.pi) / 2 + 0.5
ax.plot(x, y, zs=0, zdir='z', label='zs=0, zdir=z')
colors = ('r', 'g', 'b', 'k')
for c in colors:
x = np.random.sample(20)
y = np.random.sample(20)
ax.scatter(x, y, 0, zdir='y', c=c)
ax.legend()
ax.set_xlim3d(0, 1)
ax.set_ylim3d(0, 1)
ax.set_zlim3d(0, 1)
plt.show()

Q4:python中len函数

Python len() 方法返回字符串长度。
len()方法语法:
len( str )
返回值:
返回字符串长度。
以下实例展示了len()的使用方法:
#!/usr/bin/python
str = "this is string example....wow!!!";
print "字符串长度: ", len(str);
以上实例输出结果如下:
字符串长度:32

小提示:内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。

绘制曲线求函数 推荐文章:
推荐不满意?点这里  ››  

绘制曲线求函数