Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在3d matplotlib中模糊点_Python_Animation_Matplotlib_Plot_Blurry - Fatal编程技术网

Python 如何在3d matplotlib中模糊点

Python 如何在3d matplotlib中模糊点,python,animation,matplotlib,plot,blurry,Python,Animation,Matplotlib,Plot,Blurry,在matplotlib 3d中,是否可以根据距离视点的长度来模糊某些数据点。我知道这只会让点变得模糊 我正在寻找类似的东西 您可以使用matplotlib.cm中的一个颜色贴图进行模糊 在下面的玩具示例中,对定义每个标记颜色的z坐标进行线性插值。告诉前景和背景上的z值的限制由zbf和zbb给出 import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import matplotlib.cm as

在matplotlib 3d中,是否可以根据距离视点的长度来模糊某些数据点。我知道这只会让点变得模糊

我正在寻找类似的东西


您可以使用
matplotlib.cm
中的一个颜色贴图进行模糊

在下面的玩具示例中,对定义每个标记颜色的
z
坐标进行线性插值。告诉前景和背景上的
z
值的限制由
zbf
zbb
给出

import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import matplotlib.cm as cm
import numpy as np

n = 10
frames = 100
x = np.random.random(n)
y = np.random.random(n)
z = np.random.random(n)

zbb = 0. # z_blur_back
zbf = 1. # z_blur_fore

ax = plt.subplot(111)
fig = plt.gcf()

def animate(i):
    global x, y, z
    x += 0.01*(-0.5 + np.random.random(n))
    y += 0.01*(-0.5 + np.random.random(n))
    z += 0.05*(-0.5 + np.random.random(n))

    cmnum = (z-zbf)/(zbb-zbf)
    colors = cm.gray(cmnum) # use hot, ocean, rainbow etc...

    fig = plt.gcf()
    fig.clear()
    ax = plt.gca()
    ax.scatter(x, y, marker='o', s=200., color=colors)
    ax.set_xlim(-0.1,1.1)
    ax.set_ylim(-0.1,1.1)

ani = FuncAnimation(fig, animate, frames=xrange(frames))
ani.save('test.mp4', fps=20)

需要什么版本的matplotlib?因为当使用mpl版本1.1.1rc(Ubuntu12.04)在本地运行代码时,它似乎只会改变点的不透明度。它们也应该随机抖动一点。。。我正在使用matplotlib 1.3.0。。。