두 개의 큰 데이터 세트가 있고 서브 플롯을 사용하여 표시하려는 경우
여기에 이미지 설명 을 입력하는 대신
어떻게하면 더 잘 보일 수 있습니까? 디스플레이 y 0,30,60,90과 같습니다. 및 x 0,20,40,60,80,100
fig, ax = plt.subplots()
ax.plot(LIST1, LIST2)
ax.set(xlabel='X', ylabel='Y' title='chart')
ax.grid()
샘플 데이터로 스 니펫을 확인하세요.
strings
플롯 에 표시 하고 있었 으므로 이러한 출력을 수신했습니다. 결과를로 변환 float
하고 첫 번째 이미지를 matplotlib
보았습니다. 자체적으로 xlimit 및 ylimit를 처리합니다.
import matplotlib.pyplot as plt
import numpy as np
lists1= ['12.0', '15.0', '16.2', '16.3', '16.9', '17.5', '18.6', '19.3', '19.4', '20.2', '21.3', '22.9', '23.5', '25.2', '28.5', '30.5', '31.8', '42.5', '43.3', '45.1', '47.8', '60.4', '63.7', '65.8', '67.8', '69.9', '73.1', '76.4', '79.8', '97.8', '99.2', '100.2', '103.3', '103.6', '110.8', '111.2', '101.2', '103.0', '110.1', '112.3', '123.9']
list1=[float(i) for i in lists1]
lists2 =[ '1977', '1978', '1979', '1980', '1981', '1982', '1983', '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011','2012','2013','2014','2015','2016','2017']
list2=[int(i) for i in lists2]
fig, ax = plt.subplots()
ax.plot(list2,list1)
ax.set(xlabel='X', ylabel='Y',title='chart')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x=[15,35,24,46,45]
y=[25,53,64,35,75]
fig, ax = plt.subplots()
ax.plot(x,y)
ax.set(xlabel='X', ylabel='Y',title='chart')
plt.xticks(np.arange(1970,2030,10))
plt.show()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다