Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
Only usingpatches.Rectangle() ofplt.subplots() works properly as shown below:
fromtorchvision.datasetsimportCelebAmy_data=CelebA(root="data",split="all",target_type=["bbox","landmarks"])importmatplotlib.pyplotaspltfrommatplotlib.patchesimportRectanglefig,axes=plt.subplots(nrows=2,ncols=5,figsize=(12,6))for (im, ((x,y,w,h),lm)),axisinzip(my_data,axes.ravel()):axis.imshow(X=im)rect=Rectangle(xy=(x,y),width=w,height=h,linewidth=3,edgecolor='r',facecolor='none',clip_on=True)# Hereaxis.add_patch(p=rect)# Here
And only usingaxes.Axes.scatter() ofplt.subplots()
works properly as shown below:
fromtorchvision.datasetsimportCelebAimporttorchvisionmy_data=CelebA(root="data",split="all",target_type=["bbox","landmarks"])importmatplotlib.pyplotaspltfrommatplotlib.patchesimportRectanglefrommatplotlib.patchesimportCirclefig,axes=plt.subplots(nrows=2,ncols=5,figsize=(12,6))for (im, ((x,y,w,h),lm)),axisinzip(my_data,axes.ravel()):axis.imshow(X=im)forpx,pyinlm.split(2):# Hereaxis.scatter(x=px,y=py,c='#1f77b4')# Here
And only usingaxes.Axes.plot()
ofplt.subplots()
works properly as shown below:
fromtorchvision.datasetsimportCelebAimporttorchvisionmy_data=CelebA(root="data",split="all",target_type=["bbox","landmarks"])importmatplotlib.pyplotaspltfrommatplotlib.patchesimportRectanglefrommatplotlib.patchesimportCirclefig,axes=plt.subplots(nrows=2,ncols=5,figsize=(12,6))for (im, ((x,y,w,h),lm)),axisinzip(my_data,axes.ravel()):axis.imshow(X=im)px= []# Herepy= []# Hereforj,vinenumerate(lm):# Hereifj%2==0:# Herepx.append(v)# Hereelse:# Herepy.append(v)# Hereaxis.plot(px,py)# Here
But usingpatches.Rectangle()
ofplt.subplots()
withaxes.Axes.scatter()
ofplt.subplots()
doesn't work properly as shown below:
fromtorchvision.datasetsimportCelebAmy_data=CelebA(root="data",split="all",target_type=["bbox","landmarks"])importmatplotlib.pyplotaspltfrommatplotlib.patchesimportRectanglefig,axes=plt.subplots(nrows=2,ncols=5,figsize=(12,6))for (im, ((x,y,w,h),lm)),axisinzip(my_data,axes.ravel()):axis.imshow(X=im)rect=Rectangle(xy=(x,y),width=w,height=h,linewidth=3,edgecolor='r',facecolor='none',clip_on=True)# Hereaxis.add_patch(p=rect)# Hereforpx,pyinlm.split(2):# Hereaxis.scatter(x=px,y=py,c='#1f77b4')# Here
And usingpatches.Rectangle()
ofplt.subplots()
withaxes.Axes.plot()
ofplt.subplots()
doesn't work properly as shown below:
fromtorchvision.datasetsimportCelebAmy_data=CelebA(root="data",split="all",target_type=["bbox","landmarks"])importmatplotlib.pyplotaspltfrommatplotlib.patchesimportRectanglefig,axes=plt.subplots(nrows=2,ncols=5,figsize=(12,6))for (im, ((x,y,w,h),lm)),axisinzip(my_data,axes.ravel()):axis.imshow(X=im)rect=Rectangle(xy=(x,y),width=w,height=h,linewidth=3,edgecolor='r',facecolor='none',clip_on=True)# Hereaxis.add_patch(p=rect)# Herepx= []# Herepy= []# Hereforj,vinenumerate(lm):# Hereifj%2==0:# Herepx.append(v)# Hereelse:# Herepy.append(v)# Hereaxis.plot(px,py)# Here
So instead, I usedpatches.Rectangle()
ofplt.subplots()
withpatches.Circle() ofplt.subplots()
, then they properly work as shown below:
fromtorchvision.datasetsimportCelebAmy_data=CelebA(root="data",split="all",target_type=["bbox","landmarks"])importmatplotlib.pyplotaspltfrommatplotlib.patchesimportRectanglefrommatplotlib.patchesimportCirclefig,axes=plt.subplots(nrows=2,ncols=5,figsize=(12,6))for (im, ((x,y,w,h),lm)),axisinzip(my_data,axes.ravel()):axis.imshow(X=im)rect=Rectangle(xy=(x,y),width=w,height=h,linewidth=3,edgecolor='r',facecolor='none',clip_on=True)# Hereaxis.add_patch(p=rect)# Hereforpx,pyinlm.split(2):# Hereaxis.add_patch(p=Circle(xy=(px,py)))# Here
Proposed solution
So, it seems likematplotlib.patches works withmatplotlib.patches
sopatches.Scatter()
andpatches.Plot()
should be added.