概述
import numpy as np
import matplotlib.pyplot as plt
from random import randint
fig = plt.figure()
Wells=np.arange(0,10,1) #number of wells to plot
for i in Wells:
samp=randint(50,100) #number of samples in well
dist=0.02 #space between plots
left=0.05 #left border
right=0.05 #right border
base=0.05 #bottom border
width=((1.0-(left+right))/len(Wells)) #width of subplot
height=(1.0-base)/(100.0/samp) #height of subplot
#create subplots
ax = fig.add_axes([left+(i*width)+dist,1.0-(base+height),width-dist,height]) #left,bottom,width,height of subplot
#random data
x=np.random.random_integers(100,size=(samp))
y=np.arange(0,len(x),1)
#plot
ax.plot(x,y,alpha=0.5)
#zone area of plot
zone=samp/2.5
ax.axhspan(15,zone,color='k',alpha=0.2) #axis 'h' horizontal span
#format
ax.set_ylim(0,max(y))
ax.set_xlim(0,max(x))
ax.tick_params(axis='both',label1On=False,label2On=False)
plt.show()
xys_bot = []
xys_top = []
for i in Wells:
#
#...
#
xys_bot.append( ((x.max() - x.min())/2.,15) )
xys_top.append( ((x.max() - x.min())/2.,zone) )
if i > 0:
# bottom line
p = ConnectionPatch(xyA = xys_bot[i-1],xyB = xys_bot[i],coordsA='data',coordsB='data',axesA=fig.axes[i-1],axesB=ax,arrowstyle='-')
ax.add_artist(p)
# top line
p = ConnectionPatch(xyA = xys_top[i-1],xyB = xys_top[i],arrowstyle='-')
ax.add_artist(p)
plt.draw()
plt.show()
总结
以上是编程之家为你收集整理的python – 在matplotlib中绘制一条关联多个子图之间区域的线全部内容,希望文章能够帮你解决python – 在matplotlib中绘制一条关联多个子图之间区域的线所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧