Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

matplotlib에서 pyplot.arrow 또는 patch.Arrow를 사용하는 방법은 무엇입니까?

<시간/>

pyplot.arrow를 사용하려면 또는 patch.Arrow() matplotlib에서 다음 단계를 수행할 수 있습니다. -

  • 그림 크기를 설정하고 서브플롯 사이 및 주변 여백을 조정합니다.
  • 4개의 변수 x_tail, y_tail, x_head 및 y_head를 초기화합니다.
  • 그림과 서브플롯 세트를 생성합니다.
  • 멋진 화살표 인스턴스를 받으세요.
  • add_patch()를 사용하여 아티스트 추가(4단계) 방법.
  • 그림을 표시하려면 show()를 사용하세요. 방법.

예시

matplotlib에서 pyplot을 plt로 가져오고 패치를 mpatchesplt.rcParams["Figure.figsize"] =[7.50, 3.50]plt.rcParams["Figure.autolayout"] =Truex_tail =0.1y_tail =0.1x_head =0.9y_head로 가져옵니다. 0.9fig, ax =plt.subplots()arrow =mpatches.FancyArrowPatch((x_tail, y_tail), (x_head, y_head), mutation_scale=100, color='녹색')ax.add_patch(화살표)plt.show() 

출력

matplotlib에서 pyplot.arrow 또는 patch.Arrow를 사용하는 방법은 무엇입니까? matplotlib에서 pyplot.arrow 또는 patch.Arrow를 사용하는 방법은 무엇입니까?