SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Lorenzo I. <lor...@gm...> - 2016年04月14日 10:35:55
Dear All,
Thanks to what I found here
http://bit.ly/1qJlWkP
I discovered how to plot the convex hull around a set of points
(please have a look at the script pasted at the end of the email).
Everything is almost done,but I have a problem: my "points" are not
really point-like: they are sphere whose radius is 1 and they almost
touch each other.
I do not know how to tune the parameter s so that the radius of the
points is equal to one in the same units in which I measure the
positions of the points themselves.
Any help is appreciated.
Cheers
Lorenzo
################################################################à
import numpy as np
import pylab as pl
import scipy as sp
from scipy.spatial import ConvexHull
from scipy.spatial.distance import euclidean
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d as a3
cluster_agglomerate=np.array([[ 0.14513811, -0.18930948, -1.44428171],
 [ 0.88042945, 1.67057596, -1.45742688],
 [-1.66682741, -0.99554261, -1.70267889],
	 [-0.95535694, 2.3159907 , -1.93637881],
		 [ 1.09396798, 1.7987614 , -3.44524095],
			 [-2.63620654, 0.16588691,
 -3.02436539],
 [ 0.19027056, 2.70740725, 0.11479029],
	 [ 2.77638842, 1.70535678, -2.10208878],
		 [-0.09149779, -0.81908733, 2.07425244],
			 [-0.48408772, 0.96793567,
 1.26652603],
 [ 0.67499278, -2.5386008 , 1.39914827],
	 [ 1.02571108, -1.60932884, -0.34500693],
		 [ 2.78789155, -1.42050584, 0.59682802],
			 [-0.14688239, -2.36883246,
 3.35177362],
 [-1.71507089, 0.19184887, 2.68408562],
	 [-1.87886026, -1.58255618, 3.97006406],
		 [ 6.61540229, 1.98324725, 0.82767368],
			 [ 7.46818823, 3.00950487,
 -0.66214223],
 [ 4.80777628, 1.97159273, 1.68344958],
	 [ 6.3548727 , 2.26459561, 2.92819854],
		 [ 4.70026626, 0.44618044, 0.3866837 ],
			 [ 3.44366671, 1.87939977,
 -0.2203051 ],
 [ 2.92460648, 1.98510457, 2.37510769],
	 [ 5.07053866, -0.10349542, -1.51041234],
		 [ 7.21643437, -1.32050186, -0.70707322],
			 [ 6.93292243, 0.58458074,
 -1.2458508 ],
 [ 7.84238244, -2.97562362, -1.63914669],
	 [ 7.43212373, 0.10620418, 0.68315389],
		 [ 9.59692827, -2.0843759 , -1.26623658],
			 [ 8.34540867, -1.14927294,
 1.95073173],
 [ 6.57425162, -2.13797392, -2.94804639],
	 [ 6.93340304, -4.4591665 , -0.63578546]])
# see http://bit.ly/1qJlWkP
# Generate random points & convex hull
points = cluster_agglomerate # np.random.rand(20,3)
print "points are, ", points
hull = ConvexHull(points)
print "I calculated the convex hull"
ax = a3.Axes3D(pl.figure())
facetCol = [1, 0.0, 0.0]
ax.plot_trisurf(points[:,0], points[:,1], points[:,2],
 triangles=hull.simplices)
ax.scatter(points[:,0], points[:,1], points[:,2], s=100)
plt.axis('off')
plt.show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /