Я не совсем уверен в том, что вы спрашиваете, но вот как я мог бы изобразить что-то в этом духе ...
Соотношение сторон вашей фигуры контролируется от figsize
kwarg до plt.figure
(или plt.subplots
, в данном случае).
Остальное вы можете сделать с разумным применением annotate
.
Вот пример:
import matplotlib.pyplot as plt
import numpy as np
# Generate the data
data = (np.random.random((20, 2, 2, 1001)) - 0.5).cumsum(axis=-1)
# Set up the figure (the figsize is what's going to control your aspect ratio)
fig, axes = plt.subplots(nrows=20, ncols=2, sharex=True, figsize=(6, 10))
fig.subplots_adjust(wspace=0.1, hspace=0, bottom=0.05)
# Turn off tick labels everywhere
for ax in axes.flat:
for axis in [ax.xaxis, ax.yaxis]:
axis.set_ticklabels([])
# Plot the data
color = {(0,0):'red', (0,1):'green', (1,0):'blue', (1,1):'magenta'}
for (i,j), ax in np.ndenumerate(axes):
for k in range(2):
ax.plot(data[i,j,k,:], color=color[(j,k)])
# Add stacked titles (and text legends)
titles = [['TITLE:', 'Red: Data X', 'Green: Data Y'],
['TITLE:', 'Blue: Data W', 'Magenta: Data Z']]
for i, title in enumerate(titles):
for text, ypos in zip(title, [35, 20, 5]):
axes[0,i].annotate(text, xy=(0.05, 1.0), xytext=(0, ypos), va='bottom',
xycoords='axes fraction', textcoords='offset points')
# Add arrows on "super-Y" axes
xpos, length = -0.1, 5
axes[12,0].annotate('', xy=(xpos, 0), xytext=(xpos, length),
xycoords='axes fraction', textcoords='axes fraction',
arrowprops=dict(arrowstyle='<|-'))
axes[12,0].annotate('{0} subplots'.format(length), xy=(xpos, length/2.0),
xycoords='axes fraction', rotation=90, va='center', ha='right')
# Add arrows on "super-X" axes
ypos, length = -0.7, 1000
axes[-1,0].annotate('', xy=(0, ypos), xytext=(length, ypos),
xycoords=('data', 'axes fraction'), textcoords=('data', 'axes fraction'),
arrowprops=dict(arrowstyle='<|-'))
axes[-1,0].annotate('{0} data units'.format(length), xy=(length/2.0, ypos),
xytext=(0, 5), xycoords=('data', 'axes fraction'),
textcoords='offset points', ha='center', va='bottom')
plt.show()