Concatenate multiple histograms in matplotlib

怎甘沉沦 提交于 2020-01-06 14:46:08

问题


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).

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?


回答1:


This might be helpful:

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()

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.

source: How to remove gaps between subplots in matplotlib?



来源:https://stackoverflow.com/questions/35856319/concatenate-multiple-histograms-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!