我在一个带有周期性边界条件的盒子中有一个由N个椭圆粒子组成的系统:
import numpy as np
import matplotlib.pyplot as plt
import numpy.random as rnd
from matplotlib.patches import Ellipse
import time
infile = open ('init.txt')
N_p = 100
x, y = [], []
m = []
for i in xrange(N_p):
data = infile.readline()
raw = data.split()
x.append(float(raw[0]))
y.append(float(raw[1]))
m.append(float(raw[4]))
xnp = np.array(x)
ynp = np.array(y)
mnp = np.array(m)
fig = plt.figure(0)
ax = fig.add_subplot(111, aspect='equal')
for x, y, m in zip(xnp, ynp, mnp):
ell = Ellipse(xy=(x, y), width = 4.0, height = 2.0, angle = m)
ell.set_facecolor('blue')
ax.add_artist(ell)
ell.set_clip_box(ax.bbox)
ax.set_xlim(0, 100)
ax.set_ylim(0, 100)
fig.savefig("init.png")
plt.show()
从图像中可以看出,椭圆在边界处被切割,但我想在框的另一侧显示椭圆的剩余部分。我怎么能这样做?