我正在绘制一个由许多多边形组成的曲面。如下所示,绘图非常简单。
我看到的图片如下所示。有很大的白色空间,但图像很小。我希望图像覆盖大部分空间。我该如何实现?
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)
等等。 - tmdavisonfig.subplots_adjust(left=0, right=1, bottom=0, top=1)
将会移除轴线外部的大量空白。 - tmdavison