1

I have several time series signals (8x8) that I would like to plot using subplot. My data are stored in a matrix called H(x, y, N) where N is the number of points in each signal. I would like to display the 64 signals using subplots.

fig = figure(figsize=(12,8)) time = np.arange(0, Nt, 1) for x in range(8): for y in range(8): subplot(8,y+1,x+1) plot(time,H[x,y,:]) 

What I get is 8 signals in the first row, 4 in the second one, then 2, 2, 1, 1, 1 and 1.

1 Answer 1

2

That's not how subplot indexing works. From the docs to subplot:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

So, you want to have nrows=8, ncols=8 and then a plot_number in the range 1-64, so something like:

nrows,ncols = 8,8 for y in range(8): for x in range(8): plot_number = 8*y + x + 1 subplot(nrows,ncols,plot_number) plot(time,H[x,y,:]) # Remove tick labels if not on the bottom/left of the grid if y<7: gca().set_xticklabels([]) if x>0: gca().set_yticklabels([]) 

To remove tick labels, use gca() to get the current axes, and the set the xticklabels and yticklabels to an empty list: []

Sign up to request clarification or add additional context in comments.

3 Comments

I looked for an example online, I guess I really didn't understand how it works. Thanks a lot
Do you know how to remove the values along the axis because I have so many plots that I cannot see anything anymore?
sure, you need to remove the xticklabels and yticklabels. Try setting them to an empty list for the subplots you want to remove tick labels on. See my edit for a suggestion

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.