matplotlib 子区代码和整数错误的问题

tkclm6bt  于 2023-05-01  发布在  其他
关注(0)|答案(1)|浏览(102)

你好,我正在尝试运行以下代码:

plt.figure()
subplotsize = np.ceil(np.sqrt(len(localpeaks)))

imRawMovie = io.imread('DNAPAINT_substack.tiff')
singleFrameRawMovie = imRawMovie[30,:,:]

for l in range(0, len(localpeaks)):
  #Extract the ROI - we know it is centered around the localpeaks[l,:] position, with radius ROIradius
  ROI = singleFrameRawMovie[localpeaks[l,0]-ROIradius:localpeaks[l,0]+ROIradius+1,
                    localpeaks[l,1]-ROIradius:localpeaks[l,1]+ROIradius+1]
  #Show the ROIs in a subplot image
  plt.subplot(subplotsize,subplotsize,l+1)
  plt.imshow(ROI,cmap='gray')

我得到一个关于整数的错误。有人能帮我解决这个问题吗?我也附上了错误Image of the error的屏幕截图
我试过查找错误,但失败了

von4xj4u

von4xj4u1#

np.ceil()返回float,而不是int。使用math.ceil()

import math

subplotsize = math.ceil(math.sqrt(len(localpeaks)))

相关问题