동일한 페이지에 세 개의 서브 그림을 플로팅합니다. 나는 모든 subplots을 통해 horiontal 라인을 그리기를 원한다. 내 코드와 결과 그래프는 다음과 같은 : 나는 다시 pyplot을 사용하여 파이썬에서 여러 개의 서브 그림에 수평선을 그립니다.
: 이것은 다음을 생성
gs1 = gridspec.GridSpec(8, 2)
gs1.update(left=0.12, right=.94, wspace=0.12)
ax1 = plt.subplot(gs1[0:2, :])
ax2 = plt.subplot(gs1[3:5, :], sharey=ax1)
ax3 = plt.subplot(gs1[6:8, :], sharey=ax1)
ax1.scatter(theta_cord, density, c = 'r', marker= '1')
ax2.scatter(phi_cord, density, c = 'r', marker= '1')
ax3.scatter(r_cord, density, c = 'r', marker= '1')
ax1.set_xlabel('Theta (radians)')
ax1.set_ylabel('Galaxy count')
ax2.set_xlabel('Phi (radians)')
ax2.set_ylabel('Galaxy count')
ax3.set_xlabel('Distance (Mpc)')
ax3.set_ylabel('Galaxy count')
plt.ylim((0,0.004))
loc = plticker.MultipleLocator(base=0.001)
ax1.yaxis.set_major_locator(loc)
plt.axhline(y=0.002, xmin=0, xmax=1, hold=None)
plt.show()
(당신은 내가 플롯 중 하나에서 수평선을 얻을 수 있지만 모든 수 알 수 있습니다) 마지막 서브 플로트에 그린 선을 처음 두 개의 서브 플로트에도 표시하고 싶습니다. 어떻게해야합니까?
덜 귀하의 질문에 귀하의 축 레이블, 귀하의 실제 데이터와 같은 불필요한 세부 정보가 포함되어 있습니다. 코드가 복사하여 붙여 넣기를 실행할 수있는 것이 가장 좋습니다. – tacaswell