问题描述
我很难弄清楚如何平滑输出的图。我不希望图像如此像素化。我不确定最好的处理方法。对平滑选项不是很熟悉,因此我没有首选的方法。对于这种事情有最流行的方法吗? enter image description here 预先谢谢你。
import numpy as np
import pandas as pd
import numpy.random
import matplotlib.pyplot as plt
from matplotlib import cm as CM
from scipy.stats import gaussian_kde
import glob
import os
import matplotlib.ticker as ticker
from matplotlib.patches import Patch
from matplotlib.colors import ListedColormap,LinearSegmentedColormap
import math
for fn in filenames:
print('Processing file: ',fn)
data = pd.read_excel(fn)
data.rename(columns={'Position X': 'X','Position Y': 'Y','Area*Intensity' : 'A_I'},inplace=True)
x_coords_all = data['X']
y_coords_all = data['Y']
min_x = np.min(x_coords_all)
min_y = np.min(y_coords_all)
max_x = np.max(x_coords_all)
max_y = np.max(y_coords_all)
x_dim = max_x - min_x
y_dim = max_y - min_y
cells_x = int(x_dim) // 20
cells_y = int(y_dim) // 20
df_seg = data.loc[(data['Quanta'] >= 0)]
x_coords_seg = df_seg['X']
y_coords_seg = df_seg['Y']
fig,ax = plt.subplots()
h = ax.hist2d(x_coords_seg,y_coords_seg,bins=[cells_x,cells_y],density=False,cmap = 'nipy_spectral')
plt.colorbar(h[3],ax=ax)
plt.xticks(fontsize=8)
plt.yticks(fontsize=8)
plt.suptitle('Spacial density,Total Quanta,Grid cell = 20x20 $\mu m$')
plt.savefig(fn[:-5]+'Quanta Total' + '.png',dpi=300)
plt.clf()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)