2011-08-04 10 views
5

मेरे पास 28 लाइन x 2 कॉलम का एक सबप्लॉट है (यह वास्तव में बदल सकता है)। पहले कॉलम की सभी पंक्तियों का याक्सिस स्केल वही होना चाहिए (जो उस दूसरे कॉलम के लिए भी काम करना चाहिए) ....एक बड़ा सबप्लॉट दिखने में मदद करें nicer और स्पष्ट

सभी xaxis समान होना चाहिए।

मैं क्या करना चाहता हूं आउटपुट आकृति के अंदर कुछ बनाना है जो दिखाता है कि पहले और दूसरे कॉलम के लिए याक्सिस क्या है और दोनों स्तंभों के लिए xaxis क्या है ... मैं भी शीर्ष पर एक लेबल प्राप्त करना चाहता हूं पहले और दूसरे कॉलम पर (कह रहे हैं कि वे डेटा क्या हैं)।

मैं भूखंडों के पहलू को भी बदलना चाहता हूं ताकि इसे और अधिक स्पष्ट रूप से देखा जा सके (शायद यक्सिस पहलू के आकार में वृद्धि और xaxis आकार को थोड़ा कम करना)।

Output Figure

यह कुछ अलग हो सकता है:

subplot मैं चाहता हूँ, फिर से आकार देने के बिना, कुछ इस तरह होना चाहिए। मैं वास्तव में नहीं जानता कि मेरे अनुरोध से क्या करना संभव है।

कोड मैं अमरीकी डालर आंकड़ा (पेंट निर्मित लेबल के बिना) उत्पन्न करने के लिए: बहुत मदद के लिए

def pltconc(conc,self): 
t=self.t 
idx1=0 
conc=conc*1000000 


c=len(find(self.ml[:,3]==1)) 

from scipy.stats import scoreatpercentile #To adjust the scales 
ymin1 = max([median(scoreatpercentile(conc[:,i,:],0.05)) for i in range(28)]) 
ymax1 = max([median(scoreatpercentile(conc[:,i,:],99.95)) for i in range(28)]) 

for idx1 in range(c): 
    a=subplot(c,2,2*idx1+1, adjustable='box-forced') 
    plt.plot(t,conc[:,idx1,0],color='r') 
    plt.plot(t,conc[:,idx1,1],color='b') 
    plt.axis('tight') 
    xlim(0,max(self.t)) 
    ylim(ymin1,ymax1) 
    frame1 = plt.gca() 
    a.set_yticklabels([]) 
    a.set_xticklabels([]) 


    ax=subplot(c,2,2*idx1+2, adjustable='box-forced') 
    CBV = (conc[:,idx1,2]*100)/(90+conc[:,idx1,2]) 
    StO2 = (conc[:,idx1,0]*100)/(90+conc[:,idx1,2]) 
    ymin2 = max(median(scoreatpercentile(CBV,0.05)),median(scoreatpercentile(StO2,0.05))) 
    ymax2 = max(median(scoreatpercentile(StO2,99.95)),median(scoreatpercentile(CBV,99.95))) 
    plt.plot(t,CBV, color='m') 
    plt.plot(t,StO2, color = 'b') 
    plt.axis('tight') 
    xlim(0,max(self.t)) 
    ylim(ymin2,ymax2) 
    frame1 = plt.gca() 
    ax.set_yticklabels([]) 
    ax.set_xticklabels([]) 

धन्यवाद।

मैंने कोड बदल दिया क्योंकि मुझे एहसास हुआ है कि वे सही ढंग से स्केल नहीं किए गए थे। आउटपुट आकृति थोड़ा अलग होना चाहिए, लेकिन यह वास्तव में इस प्रश्न के उद्देश्य के लिए महत्वपूर्ण नहीं है।

उत्तर

3

मैं पूरी तरह सुनिश्चित करें कि आप क्या कह रहे हैं नहीं कर रहा हूँ, लेकिन यहाँ है कि कैसे मैं उन पंक्तियों के साथ कुछ की साजिश रचने के बारे में जाना चाहते हैं ...

अपने आंकड़ा के लिए पहलू अनुपात plt.figure करने के लिए figsize kwarg द्वारा नियंत्रित किया जाता (या 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() 

enter image description here

+0

ये है कि लगभग कुछ liek है कि मैं चाहता था .. केवल एक चीज है कि मैं 2 superY तीर (प्रत्येक स्तंभ differente पैमाने है) और मैं चाहता हूँ की जरूरत है कि छिद्रों पर होने वाली चीजें तीर पर जाती हैं (मुझे वह तीर दिखाना है जो प्रत्येक कॉलम के लिए वाई स्केल क्या है ...) ... विचार मिला ?? –

+0

बीटीडब्ल्यू, मुझे दूसरे तीरों को बनाना है, इसे ग्राफिक्स के पैमाने को दिखाने की जरूरत है ... और तीरों को एक शीर्षक भी होना चाहिए (टाइम पॉइंट्स की तरह कुछ) –

संबंधित मुद्दे