三维散点图和求幂运算
作者:互联网
绘制三维散点图
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(10,8)) -建画布
ax = fig.add_subplot(111, projection='3d') -三维画布
某一特征利用布尔索引进行分组,分为三组
iris_all_class0 = iris_all[iris_all['target']==0].values
iris_all_class1 = iris_all[iris_all['target']==1].values
iris_all_class2 = iris_all[iris_all['target']==2].values
分别画出,x,y,z三轴,参数分别为x,y,hue,图例
ax.scatter(iris_all_class0[:,0], iris_all_class0[:,1], iris_all_class0[:,2],label='setosa')
ax.scatter(iris_all_class1[:,0],iris_all_class1[:,1],iris_all_class1[:,2],label='versicolor')
ax.scatter(iris_all_class2[:,0], iris_all_class2[:,1],iris_all_class2[:,2],label='virginica')
plt.legend() 显示图例
plt.show()
- np.exp() 求幂运算
import numpy as np
print(np.exp(0)) e的0次方 = 1
print(np.exp(1)) e的1次方 = e = 2.718281828459045
print(np.exp(1)) e的二次方 = 7.38905609893065
标签:iris,运算,散点图,三维,exp,np,ax,class2,class0 来源: https://blog.csdn.net/koksir/article/details/115279637