散点图

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

ax = plt.figure().add_subplot(111, projection = '3d') 
#基于ax变量绘制三维图 
#xs表示x方向的变量 
#ys表示y方向的变量 
#zs表示z方向的变量,这三个方向上的变量都可以用list的形式表示 
#m表示点的形式,o是圆形的点,^是三角形(marker) 
#c表示颜色(color for short) 
ax.scatter(xs, ys, zs, c = 'r', marker = '^') #点为红色三角形 
 
#设置坐标轴 
ax.set_xlabel('X Label') 
ax.set_ylabel('Y Label') 
ax.set_zlabel('Z Label') 
 
#显示图像 
plt.show() 

参考网址:https://www.jb51.net/article/130154.htm

matplotlib中颜色及线条控制

ax.scatter(xs, ys, zs, c = ‘r’, marker = ‘^’) # c为颜色,marker为点样式
颜色:
python matplotlib相关marker样式:
‘.’ point marker
‘,’ pixel marker
‘o’ circle marker
‘v’ triangle_down marker
‘^’ triangle_up marker
‘<’ triangle_left marker
‘>’ triangle_right marker
‘1’ tri_down marker
‘2’ tri_up marker
‘3’ tri_left marker
‘4’ tri_right marker
‘s’ square marker
‘p’ pentagon marker
‘*’ star marker
‘h’ hexagon1 marker
‘H’ hexagon2 marker
‘+’ plus marker
‘x’ x marker
‘D’ diamond marker
‘d’ thin_diamond marker
‘|’ vline marker
‘_’ hline marker

参考网址:https://www.cnblogs.com/darkknightzh/p/6117528.html

注意

注意事项:

运用plt.show()必须手动关闭绘图窗口程序才会往下执行,如果希望图像显示一定时间后继续执行,则用plt.pause(0.5),括号内为延时关闭的秒数。

matplotlib和mayavi冲突,两者一起安装时,mayavi会出错。

相关文章:

  • 2022-01-26
  • 2022-01-08
  • 2021-12-02
  • 2022-12-23
  • 2021-04-11
  • 2021-05-26
  • 2021-11-20
  • 2021-12-22
猜你喜欢
  • 2021-10-18
  • 2021-09-16
  • 2021-06-25
  • 2021-11-14
  • 2021-08-03
相关资源
相似解决方案