I would like to plot 2 circles with differents radius using matplotlib given their faces and vertices. This is my code to define the circles and to plot them.
r2,r3=2,3
n_t3=5
n_t2=n_t2
theta_t3=torch.linspace(0,2*torch.pi,n_t3,device=torchdeviceId)
VT3 = torch.stack((r3*torch.cos(theta_t3),r3*torch.sin(theta_t3)),dim=1)
theta_t2=torch.linspace(0,2*torch.pi,n_t2,device=torchdeviceId)
VT2 = torch.stack((r2*torch.cos(theta_t2),r2*torch.sin(theta_t2)),dim=1)
VT=torch.vstack((VT2,VT3))
FT3 = torch.cat((torch.arange(0,n_t3-1).reshape(n_t3-1,1),torch.arange(1,n_t3).reshape(n_t3-1,1)),dim=1)
FT2 = torch.cat((torch.arange(n_t3,n_t3+n_t2-1).reshape(n_t2-1,1),torch.arange(n_t3+1,n_t3+n_t2).reshape(n_t2-1,1)),dim=1)
FT=torch.vstack((FT2,FT3)).to(torchdeviceId)
xt, yt = (
VT[FT,0].detach().cpu().numpy(),
VT[FT,1].detach().cpu().numpy(),
)
plt.figure()
plt.plot(xt,yt,label='target',marker='x',markersize=10,alpha=0.2,lw=10);
plt.show()
But i have this weird result where the two circles are linked even if there is no faces linking them in FT.
Do you have any ideas what is the reason ?
source https://stackoverflow.com/questions/77881386/plot-lines-using-vertices-and-faces-in-matplotlib
Comments
Post a Comment