0

I am doing some visualizations for a wavelet presentation. I need to prepare a plot similar to this one on right side:

Image

I have been trying to reach this goal with spectogram, and I am trying for more than hour to find at least name of such plot.

This plot represents coefficients of details of a wavelet transformation at different levels (1, 2, 3, and 4). On the left side, you see a function with a threshold. The coefficients value is represented by color (black close to 0, brownie higher value).

With every level of wavelet decomposition the number of coefficients is reduced by half. So one level small ranges of samples, four levels four times larger samples.

How can I do that?

4

1 回答 1

1

好吧,您的问题假设了其他一些问题,但我认为您可能正在寻找pcolormesh。例如以这种方式使用(我将它放在一个网格中,就像您的示例图片一样,数据是随机生成的):

import matplotlib.pyplot as plt
import numpy as np

ax1 = plt.subplot2grid((4,4),(0, 0),rowspan=1,colspan=1)
ax2 = plt.subplot2grid((4,4),(1, 0),rowspan=1,colspan=1)
ax3 = plt.subplot2grid((4,4),(2, 0),rowspan=1,colspan=1)
ax4 = plt.subplot2grid((4,4),(3, 0),rowspan=1,colspan=1)

ax5 = plt.subplot2grid((4,4),(0, 1),rowspan=2,colspan=3)
ax6 = plt.subplot2grid((4,4),(2, 1),rowspan=2,colspan=3)

ax1.plot(range(100),np.random.randint(-100,100,100)/np.arange(1,101,1)**1,color='green')
ax1.axhline(10,color='orange',linestyle='--')
ax1.axhline(-10,color='orange',linestyle='--')
ax1.set_ylim(-20,20)
ax1.set_xticks([])
ax1.set_ylabel('D4',rotation=0)

ax2.plot(range(100),np.random.randint(-100,100,100)/np.arange(1,101,1)**1,color='green')
ax2.axhline(10,color='orange',linestyle='--')
ax2.axhline(-10,color='orange',linestyle='--')
ax2.set_ylim(-20,20)
ax2.set_xticks([])
ax2.set_ylabel('D3',rotation=0)

ax3.plot(range(100),np.random.randint(-100,100,100)/np.arange(1,101,1)**1,color='green')
ax3.axhline(10,color='orange',linestyle='--')
ax3.axhline(-10,color='orange',linestyle='--')
ax3.set_ylim(-20,20)
ax3.set_xticks([])
ax3.set_ylabel('D2',rotation=0)

ax4.plot(range(100),np.random.randint(-100,100,100)/np.arange(1,101,1)**1,color='green')
ax4.axhline(10,color='orange',linestyle='--')
ax4.axhline(-10,color='orange',linestyle='--')
ax4.set_ylim(-20,20)
#ax4.set_xticks([])
ax4.set_ylabel('D1',rotation=0)

X,Y = np.meshgrid(range(1000),range(4))
Z = np.random.randint(0,100,(4,1000))

ax5.pcolormesh(X,Y,Z,cmap = 'copper')
ax5.set_yticks([i for i in range(4)])

Zm = np.ma.masked_where(Z<90,Z)
ax6.pcolormesh(X,Y,Zm,cmap = 'copper')
ax6.set_yticks([i for i in range(4)])

plt.show()

结果是这样的:

subplot2grid 和 pcolormesh

于 2016-04-21T09:27:54.087 回答