没有合适的资源?快使用搜索试试~ 我知道了~
首页matplotlib在python上绘制3D散点图实例详解
matplotlib在python上绘制3D散点图实例详解
2.4k 浏览量
更新于2023-05-26
评论
收藏 92KB PDF 举报
主要介绍了matplotlib在python上绘制3D散点图实例详解,首先介绍了官网的实例,然后分享了本文简单代码示例,具有一定借鉴价值,需要的朋友可以了解下。
资源详情
资源评论
资源推荐

matplotlib在在python上绘制上绘制3D散点图实例详解散点图实例详解
主要介绍了matplotlib在python上绘制3D散点图实例详解,首先介绍了官网的实例,然后分享了本文简单代码示
例,具有一定借鉴价值,需要的朋友可以了解下。
大家可以先参考官方演示文档:
效果图:
'''
==============
3D scatterplot
==============
Demonstration of a basic scatterplot in 3D.
'''
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
def randrange(n, vmin, vmax):
'''
Helper function to make an array of random numbers having shape (n, )
with each number distributed Uniform(vmin, vmax).
'''
return (vmax - vmin)*np.random.rand(n) + vmin
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
# For each set of style and range settings, plot n random points in the box
# defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh].
for c, m, zlow, zhigh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
xs = randrange(n, 23, 32)
ys = randrange(n, 0, 100)
zs = randrange(n, zlow, zhigh)
ax.scatter(xs, ys, zs, c=c, marker=m)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()
以上是官网上的代码示例及演示结果,下面分享下本文代码示例。
本实例需要导入第三包:
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0