2013-05-07 4 views

답변

0

subplots 명령을 사용하여이를 수행 할 수 있습니다. py.subplot(2,2,1)과 같이 간단 할 수 있습니다. 여기서 처음 두 숫자는 플롯의 기하학 (2x2)을 나타내고 세 번째 숫자는 현재 플롯 번호입니다. 일반적으로 다음과 같은 예를 들어이 두 축이 있기 때문에 예상대로 py.xlabel 같은 일들이 작동하지 않을 수 있습니다 의미

import pylab as py 

# Make some data 
x = py.linspace(0,10,1000) 
cos_x = py.cos(x) 
sin_x = py.sin(x) 

# Initiate a figure, there are other options in addition to figsize 
fig = py.figure(figsize=(6,6)) 

# Plot the first set of data on ax1 
ax1 = fig.add_subplot(2,1,1) 
ax1.plot(x,sin_x) 

# Plot the second set of data on ax2 
ax2 = fig.add_subplot(2,1,2) 
ax2.plot(x,cos_x) 

# This final line can be used to adjust the subplots, if uncommentted it will remove all white space 
#fig.subplots_adjust(left=0.13, right=0.9, top=0.9, bottom=0.12,hspace=0.0,wspace=0.0) 

Produces this image

공지 사항에서와 같이 명시하는 것이 좋습니다. 대신 ax1.set_xlabel("..")을 지정하면 코드를 읽기 쉽게 만듭니다.

더 많은 예제를 찾을 수 있습니다. here.

관련 문제