ポリゴンの束でサーフェスをプロットしています。プロットは以下のように非常に簡単です。Axes3d(matplotlib)の空白を削除する
def plotSurface(cell, numOfLayer, name=None, alpha = 0.5):
#import the libraries
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import numpy as np
import matplotlib.pyplot as plt
#limits of the plot
radius = (numOfLayer>1)*(np.sqrt(3.)*(numOfLayer-1)-Length)+Length#the radius of circle to be projected on
#plotting part
fig = plt.figure(frameon=False,figsize=(12,10))
ax = Axes3D(fig)
ax.set_xlim((-2*radius,2*radius))
ax.set_ylim((-2*radius,2*radius))
ax.set_zlim((-0.5*radius,2*radius))
ax.axis('off')
#fig = plt.figure()
#ax = fig.gca(projection='3d')
##iterating through the cell##
for stuff happening here : verts are the polygon vertices
#adding to 3d plot
ax.add_collection3d(Poly3DCollection(verts,alpha = alpha))
if name == None:#plot the figure
plt.show()
else:
plt.savefig(name,bbox_inches='tight')
return
イメージは次のようになります。小さい白い隙間があります。私はその人物の大部分をカバーしたい。 どうすれば実現できますか?
あなたの軸の限界を減らしますか?例えば'ax.set_xlim(-1.1 * radius、1.1 * radius)'など – tom
軸の制限はありません。私はちょうどプロットされた形状に合っています。これは解決策ではありません –
'fig.subplots_adjust(左= 0、右= 1、下= 0、上= 1)'は軸の外の空白をたくさん削除します – tom