使用ax.scatter函数创建了3D散点图。 我们通过传递x、y和z参数来指定每个散点的位置。 c参数指定了散点的颜色,可以使用一个数值数组来表示不同的颜色值。 cmap参数指定了颜色映射,这里我们使用了viridis颜色映射。 marker参数指定了散点的形状,这里我们使用了圆形。 使用ax.set_xlabel、ax.set_ylabel和ax.set_...
Scatter 的例子 ➤03绘制3D Surface (1) Ex1 3D surface #!/usr//bin/python # -*- : gbk-*- #*** TEST2.PY -- by Dr. ZhuoQing 2020-11-16 # # Note: #*** from headm import * from mpl_toolkitsmplot3d import axes3d ax = plt.axes(projection='3d') x = arange(-...
0]sepal_width=iris.data[:,1]target=iris.targetfig,ax=plt.subplots()# 创建散点图plt.scatter(sepal_length,sepal_width,c=target,cmap='rainbow')# 添加标题和轴标签plt.title('Iris sepal length vs width'
) ➤02 绘制Scatter 利用和上面的相同绘制命令,将原来plot修改成为 scatter即可 代码语言:javascript 代码运行次数:0 运行 AI代码解释 from mpltoolkits.mplot3d import axes3d ax = plt.axes(projection'3d') angle= linspace(0, 2*pi*5, 40) x = cosangle) y = sin(angle) z = linspace(...
将原来的plot3D修改成为 scatter即可。 frommpl_toolkits.mplot3dimportaxes3d ax=plt.axes(projection='3d')angle=linspace(0,2*pi*5,40)x=cos(angle)y=sin(angle)z=linspace(0,5,40)ax.scatter(x,y,z,color='b')ax.set_xlabel('X Axes')ax.set_ylabel('Y Axes')ax.set_zlabel('Z Axes')plt...
ax1.scatter3D(xd,yd,zd, cmap='Blues') #绘制散点图 ax1.plot3D(x,y,z,'gray') #绘制空间曲线 plt.show() 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 效果图如下: 3、3D曲面 下一步画3D曲面: fig = plt.figure() #定义新的三维坐标轴 ...
"""使用scatter()绘制散点图""" import matplotlib.pyplot as plt x_values = range(1, 1001) y_values = [x*x for x in x_values] ''' scatter() x:横坐标 y:纵坐标 s:点的尺寸 ''' plt.scatter(x_values, y_values, s=10)
figure() ax = Axes3D(fig) ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='summer') ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('z') ax.set_zlim(-1.5,1.5) plt.show() 本期的介绍就到这里了,文中代码可以横向滑动浏览,为方便实操,相关的代码和样例存已存放至...
cmap:图层 code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 frommpl_toolkits.mplot3dimportAxes3D importmatplotlib.pyplot as plt frommatplotlibimportcm frommatplotlib.tickerimportLinearLocator, FormatStrFormatter ...
#通过scatter函数的s参数和c参数控制气泡的面积和颜色 #颜色映射,通过cmap参数指定颜色映射 plt.scatter(income, outcome, s=nums*30, c=nums, cmap='Reds') #显示颜色条 plt.colorbar() plt.show() 面积图 # -*- coding: utf-8 -*- #面积图 #面积图又叫堆叠折线图,是在折线图的基础上,对折线以下...