0

I am trying to plot an error ellipsoid in 3D. This is ofcourse not that hard, but I found troubles with the collors. The colormap that I used use the Z values for the color. I would like that the describes the relationship of the distance between a point on the ellipsoid and another (for simple use the centre) point.

Now the collor change from bottom to top, but I would like that is also has a horizontal change due to a change in the different axes.

Is there a way to manipulate the colormap so it shows the distances instead of the value Z ?

I thought maybe it is possible to greate a grid, same as the Z, but instead of the Z points it calculates the distance. Is it possible to use another 2d array for the colormap instead of the default Z?

Thanks for your help

3dSpatialUser
  • 2,034
  • 1
  • 9
  • 18

1 Answers1

0

Well i have the answer found. The following code generates the ellispoid and its distances:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)

x = 0.5 * np.outer(np.cos(u), np.sin(v))
y = 0.1 * np.outer(np.sin(u), np.sin(v))
z = 0.2 * np.outer(1, np.cos(v))
T = (x**2+y**2+z**2)**(1/2)
ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=cm.jet(T/float(T.max())))
#a = [max(x), max(y), max(z)]

ax.set_xlim([-0.3, 0.3])
ax.set_ylim([-0.3, 0.3])
ax.set_zlim([-0.3, 0.3])
plt.show()

the trick was to use facecolors to set the colored surface to the other dataset. The answer is found here: Representing 4D data in mplot 3D using colormaps

Maybe there will be somebody else with the same problem, so that is the reason why I post my own anwser.

Community
  • 1
  • 1
3dSpatialUser
  • 2,034
  • 1
  • 9
  • 18