一堆直方图彼此相邻

时间:2014-08-06 16:33:43

标签: python matplotlib plot histogram

this图中,在第一个图中,网格将图形划分为" windows"并且每个窗口在子窗口中划分(用let表示5个数据)。 然后计算并保存每个子窗口的斜率。 接下来,我将极坐标平面划分为16个象限,并计算哪个象限对应于每个斜率。所以,我得到这样的东西:

1,1,1,1,1,1,1,1,1,1,1,2,2,2,3,4
4,1,-1,-2,...

在上面的数据集中,每个数字都是象限,表示子窗口的斜率,每行代表一个窗口(直方图是用这个数据集计算的)。

我要找的是顶部的数字,第二个图显示了相应窗口下每个窗口的直方图。 我可以从matplotlib页面获得this,但这些示例都没有接近我需要的,因为我需要彼此相邻的直方图而不会相互阻塞。 有时,根据使用的参数,在同一图中可能超过800个直方图。

1 个答案:

答案 0 :(得分:0)

以下是一个示例,说明如何使用Gridspec在较大的地块下方并排显示多个地块:

import numpy as np
import matplotlib.pyplot as plt

# generate some data
x = np.arange(0, 10, 0.2)
y = np.sin(x)

# plot it
fig = plt.figure(figsize=(8, 6))
ax0 = plt.subplot2grid((2, 4), (0, 0), colspan=4)
ax0.plot(x, y)
ax1 = plt.subplot2grid((2, 4), (1, 0))
ax1.hist(y)
ax2 = plt.subplot2grid((2, 4), (1, 1))
ax2.hist(y)
ax2.set_yticklabels([])
ax2.set_yticks([])
ax3 = plt.subplot2grid((2, 4), (1, 2))
ax3.hist(y)
ax3.set_yticklabels([])
ax3.set_yticks([])
ax4 = plt.subplot2grid((2, 4), (1, 3))
ax4.hist(y)
ax4.set_yticklabels([])
ax4.set_yticks([])

plt.subplots_adjust(wspace=0) # no space left between hists in 2nd row

结果: enter image description here