连接matplotlib中的多个直方图 [英] Concatenate multiple histograms in matplotlib

查看:302
本文介绍了连接matplotlib中的多个直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一组时间序列数据.我按时间将这个集合分为108个窗口(单个时间窗口为1个月长).然后,我为每个窗口绘制一个直方图.所以我有108个直方图,从时间窗口1到窗口108,它们按时间顺序排列(从2006年11月到2015年10月,有108个时间窗口).

I am dealing with a set of time series data. And I have separated this set into 108 windows by time(a single time window is 1-month long). And then I plot a histogram for each window. So I have 108 histograms, from time window1 to window108 they are in chronological order(from November 2006 to October 2015, 108 time windows).

我想做什么: 是将所有这108个直方图绘制为一个水平长直方图.因此,就像完全添加它们一样.例如,绘制window1的直方图,然后在window1的直方图之后没有任何间隙的情况下,需要window2和3,4,5,6,...直到窗口108都有直方图.在Python中?

What I want to do: is to plot all these 108 histograms as a one horizontally long histogram. So it is like to add them altogether. For example, plot histogram for window1, and right after the histogram for window1 without having any gap there need to be a histogram for window2 and 3,4,5,6,,,,,,until window 108. How do I do this in Python?

推荐答案

这可能会有所帮助:

plt.figure(figsize = (4,4))
gs1 = gridspec.GridSpec(4, 4)
gs1.update(wspace=0.0, hspace=0.) # set the spacing between axes. 

for i in range(16):
    ax1 = plt.subplot(gs1[i])
    plt.axis('on')
    ax1.set_xticklabels([])
    ax1.set_yticklabels([])
    ax1.set_aspect('equal')
#     plt.subp

plt.show()

您需要控制子图之间的间距. for循环删除刻度线标签并执行其他一些格式设置,并且您想根据情况进行更改.

You need to control the spacing between subplots. The for loop removes the tick labels and does some other formatting, and you want to change them for your situation.

来源: 如何消除matplotlib中子图之间的间隙?

这篇关于连接matplotlib中的多个直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆