2011-08-04 5 views
5

28 줄 x 2 줄의 서브 플로트가 있습니다 (실제로 변경할 수 있음). 1 열의 모든 행의 y 축 규모는 동일해야합니다 (두 번째 열에서도 마찬가지입니다).큰 서브 플롯을 더 멋지고 선명하게 보이게 만드는 데 도움이됩니다.

모든 x 축은 동일해야합니다.

내가하고 싶은 것은 출력 그림에서 1 번째와 2 번째 열의 yaxis와 두 열의 xaxis가 무엇인지를 보여주는 것입니다 ... 또한 위로 레이블을 가져 오려고합니다. 첫 번째와 두 번째 열 (그 데이터가 무엇인지 말함)에서

또한 플롯의 외관을 변경하여 더 명확하게 볼 수 있습니다 (아마도 yaxis 크기를 늘리고 xaxis 크기를 약간 줄임).

Output Figure

그것은 다른 무언가가 될 수 있습니다 다시 크기 조정없이

내가 원하는 부가 적 줄거리는이 같은해야한다. 나는 정말로 내 요청을 만들 수 있는지 모른다.

(페인트 만든 레이블이없는) 그림을 생성하는 코드 내가 미화 :

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([]) 

덕분에 많이 도움을.

올바르게 스케일되지 않았기 때문에 코드가 변경되었습니다. 출력 수치는 약간 달라야하지만이 질문에 중요한 것은 아닙니다. 당신의 그림의 가로 세로 비율이 plt.figurefigsize kwarg에 의해 제어되는

답변

3

난 당신이 요구하는지 전혀 모르겠어요,하지만 난 그 라인을 따라 뭔가 음모를 꾸미고에 대한 가고 싶어 어떻게 여기에 ... (또는이 경우 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 화살표 내가 원하는과 (쉽게 구분할 규모가 각 열을) 필요하다 grapchis에 있어야했던 진드기가 화살표로 이동한다는 것 (나는 화살표로 각 열의 y 축척을 보여줍니다.) ... 아이디어가 있습니까? –

+0

Btw, 두 번째 화살표를 만들면 그래픽의 크기를 보여줄 필요가 있습니다 ... 그리고 화살표에는 제목도 필요합니다 (시간 지점과 같은 것) –

관련 문제