简体   繁体   English

在python中平滑2D地图

[英]Smoothing 2D map in python

is there any way to smooth 2D map? 有什么方法可以平滑2D地图? Here is what I have got 这是我所得到的 在此处输入图片说明 and I would like to smooth it. 我想使它顺利。 Measurement step was to big which results with such "bad" spectrum... 测量步骤太大,导致这种“不良”频谱。

Here is a part of my code: 这是我的代码的一部分:

    X, Y = np.meshgrid(x,y)
    fig, ax = plt.subplots()
    plt.xlim(235,420)
    plt.xticks(np.arange(235,415,30))
    plt.yticks(np.arange(0,360,50))
    cs = ax.pcolormesh(X,Y,A,cmap=cm.rainbow, vmin = 0)#Greys_r
    plt.xlabel('wavelength [nm]')
    plt.ylabel('temperature [K]')
    plt.title(sample)
    cbar = fig.colorbar(cs)
    cbar.formatter.set_powerlimits((0, 0))
    cbar.update_ticks()

I found a way to do it. 我找到了一种方法。 Here is how: 方法如下:

    fig = plt.figure()
    ax = fig.add_subplot(111)
    im = NonUniformImage(ax, interpolation='bilinear', extent=(180, 300, 10, 350), cmap=cm.jet)
    im.set_data(x, y, A)
    ax.images.append(im)
    ax.set_xlim(180, 300)
    ax.set_ylim(10, 350)
    plt.xlabel('wavelength [nm]')
    plt.ylabel('temperature [K]')
    plt.title(sample)
    cbar = fig.colorbar(im)
    cbar.formatter.set_powerlimits((0, 0))
    cbar.update_ticks()
    plt.savefig('map.png')
    plt.show()
    plt.close()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM