我试图绘制一些数据并创建了一个循环,以便更有效地加载图像。
然而,在我绘制数据之后,我意识到我绘制的图像越多,我的图表上出现的颜色条就越多......以前绘图中的颜色条似乎只是停留在周围并且不会消失......
有什么建议可以摆脱多余的颜色条吗?多谢你们!
import tifffile as tiff
import numpy as np
from tkinter import filedialog
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
#------------------------------------------------------------------
# Calculate the net OD data from the pre-scanned and irradiated films using calibration curve
# Calibration Film Area x -> 250:350 ; y -> 140:250
refpvpre = 35000
refpvpost = 35000
def polynomial_2_function(x, a, b, c):
return a*x**2 + b*x + c
#-------------------------------------------------------------------
nfilm = int(input("Please type in the number of films you would like to analyse: "))
for x in range(nfilm): # Start a loop for reading nfilm number of films (nfilm = 11)
pre_scan_filepath = filedialog.askopenfilename(title = "Please select a pre-scanned film")
blank_image = tiff.imread(pre_scan_filepath)
bgdpv = np.mean(blank_image[50:150, 100:200, 1]) # Calculate the background pixel value
pre_aoi = blank_image[140:250, 250:350, 1] + (refpvpre - bgdpv) # Correct the pixel value using reference
post_scan_filepath = filedialog.askopenfilename(title = "Please select an irradiated film")
image = tiff.imread(post_scan_filepath)
bgdpv = np.mean(image[50:150, 100:200, 1]) # Calculate the background pixel value
post_aoi = image[140:250, 250:350, 1] + refpvpost - bgdpv # Correct the pixel value using reference
data = np.log10(pre_aoi/post_aoi)
data = np.flipud(data.transpose()) # Set the image in the right orientation
# define 2nd order polynomial fitting function
dose_data = polynomial_2_function(data, 43.411, 6.518, 0.6428)
savename = input("Please type in the file name you would like to save your image as: ") + '.tif'
imgplot = plt.imshow(dose_data, extent = [0,4,0,6], aspect = 'auto')
imgplot.set_cmap('nipy_spectral')
plt.colorbar()
plt.savefig(savename)
带有两个颜色条的图像
带有更多颜色条的图像