2016-09-13 20 views
5

Dinamik olarak oluşturduğum ikide iki çizimi var. İlk satırda, ikinci sıra CDF'lerinde yoğunluk fonksiyonlarını çizmek istiyorum. I Her sıra ayrı ayrı keskin mi?

  • kolonların her

    paylaşmak isteyen x
  • sıraların her biri, iki nesne dikey olarak hizalanmış y

aynı X-eksenine sahip paylaşma ve iki parsel yatay olarak hizalanmış aynı y eksenine sahip olmak. Bununla birlikte, sharex ve sharey, ve sharey, tüm alt alt siteler için aynı olmaya zorlarlar. Bu tür eksen paylaşımını nasıl düzeltebilirim? Ben elle her bir hisse ortağı eksenleri de o olabilir, ama bu izler jenerik yapısı ile işe yaramaz anlıyoruz:

fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True) 
for i, lam in enumerate(lams): 
    axesNow = [axs[i] for axs in axes] # pick the ith column from axes 
    for i, Param.p in enumerate(pp): 
     axesNow[0].plot(somethingWithPDF) 
     axesNow[1].plot(somethingWithCDF) 

for ax in axes.flatten(): ax.legend() 

enter image description here

cevap

-1

Ya tüm eksenler inşa edilir böyle bir şey, hakkında bireysel olarak:

x1 = np.arange(5) 
y1 = np.arange(3, 8) 
ax1 = plt.subplot(223) 
ax1.plot(x1, y1) 
ax1.set_title("ax1") 

x2 = np.arange(5, 10) 
y2 = np.arange(3, 8) 
ax2 = plt.subplot(224, sharey=ax1) 
ax2.plot(x2, y2) 
ax2.set_title("ax2") 
#plt.setp(ax2.get_yticklabels(), visible=False) # Use this to hide axes labels 


x3 = x1 
y3 = np.arange(13, 8, -1) 
ax3 = plt.subplot(221, sharex=ax1) 
ax3.plot(x3, y3) 
ax3.set_title("ax3") 
#plt.setp(ax3.get_xticklabels(), visible=False) 


x4 = x2 
y4 = y3 
ax4 = plt.subplot(222, sharex=ax2, sharey=ax3) 
ax4.plot(x4, y4) 
ax4.set_title("ax4") 
#plt.setp(ax4.get_xticklabels(), visible=False) 
#plt.setp(ax4.get_yticklabels(), visible=False) 

plt.show() 

enter image description here

+0

, bir jenerik (non-birey) yaklaşımı – FooBar

+0

Daha kod arayan ve farenorth en fazla yanıt değiştirmek için çok zor oldu. – naught101

10

pyplot.subplots documentationaçıklar sharex ve sharey kwargs içinve 'row' seçenekleri. Özellikle, istediğiniz düşünüyorum:

gerçekten çalışır
fig, axes = plt.subplots(nrows=2, ncols=2, sharex='col', sharey='row') 
İlgili konular