注意:首先点击图片以了解图片之间的区别。
我已经阅读了stackoverflow提供的所有链接。通过python创建图像后,出现了问题。问题是我的图像.jpg
中的图片(灰色框)正在移动,但位置不固定。另一个问题是我要删除的图像中有空白。
有一个灰框位置...
具有不同位置的灰框.....
我用于生成图像的主要代码如下:
import re
from os import listdir
from os.path import isfile, join
mypath = "/home/at-lab/Nutakki/All_set/excel files/episode0/"
files = [f for f in listdir(mypath) if isfile(join(mypath, f))]
pattern = re.compile(r"\d+")
files = sorted(files, key = lambda files : int(pattern.findall(files)[0]) )
fig=plt.figure(figsize=(6,6)) ##to obtain figure and dimensions of graph
for index, i in enumerate(files):
#ax=fig.add_subplot(111,projection='3d') ## to have a broad view of figure
ax = fig.add_axes([0,0,1,1], projection='3d')
#plot planes
p = Rectangle((0,-0.7), 4.5,1.4, color="lightgrey", alpha=0.2) #plots the background frame
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z=0, zdir="z")
j=pd.read_excel(i) ##to read the excel file format
X=j['x'] ## to import the variable on to axes from data set
Y=j['y']
Z=j['z']
a=j['x']##import centre of mass from excel file format
b=j['y']
c=j['z']
q1=j['q1'],##attaining quaternons from excel file format. (comma(,) transformed series to tuple)
q2=j['q2'],
q3=j['q3'],
q4=j['q4'],
m2,n,o,p=np.array([q1,q2,q3,q4]) ## assigning quaternions to variables had converted tuple to float
Rot_Mat=QtoR(m2,n,o,p)
#cuboid initialising parameters
center = [a[0], b[0], c[0]] ##centre of the body
length = 0.3 ##defining length, breadth, height
width = 0.4
height = 0.1
side = np.zeros((8,3)) ###This numpy vector will be used to store the position of the sides
#rotate the axes and update
for angle in range(0, 360):
ax.view_init(90, angle)
from time import time
start=time()
end=time()
time=end-start
cuboid(center, (length, width, height)) #to execute the defined cuboid
print('index = ',index)
print('time_lapse = ',time)
plt.savefig('packetone {0}.jpg'.format(index))
pl.clf()
我需要在整个图像中使用灰框和黑框。
注意:应该没有空格,并且灰色框不应移动其位置。