Python 데이터 시각 화 그림 실현 과정 상세 설명

python 그림 분포 도 코드 예제:

# encoding=utf-8
import matplotlib.pyplot as plt
from pylab import * #     
 
mpl.rcParams['font.sans-serif'] = ['SimHei']
# 'mentioned0cluster',
names = ['mentioned1cluster','mentioned2cluster', 'mentioned3cluster', 'mentioned4cluster', 'mentioned5cluster', 'mentioned6cluster', 'mentioned7cluster', 'mentioned8cluster', 'mentioned9cluster', 'mentioned10cluster']
x = range(len(names))
# y_0625 = [39266,56796,42996,24872,13849,8609,5331,1971,554,169,26]
 
y_0626_1=[4793,100,0,0,0,0,0,0,0,0]
# y_0626_2=[2622,203,0,0,0,0,0,0,0,0,0]
 
# plt.plot(x, y, 'ro-')
# plt.plot(x, y1, 'bo-')
# pl.xlim(-1, 11) #        
# pl.ylim(-1, 110) #        
plt.plot(x, y_0626_1, marker='o', mec='r', mfc='w', label='HighRating:MentionedClusterNum Distribution')
# plt.plot(x, y_0626_2, marker='o', mec='r', mfc='w', label='LowRating:MentionedClusterNum Distribution')
# plt.plot(x, y1, marker='*', ms=10, label=u'y=x^3   ')
plt.legend() #      
plt.xticks(x, names, rotation=45)
plt.margins(0)
plt.subplots_adjust(bottom=0.15)
# plt.xlabel(u"time(s)  ") # X   
plt.xlabel("clusters")
plt.ylabel("number of reviews") # Y   
plt.title("A simple plot") #   
 
plt.show()
효 과 는 다음 과 같 습 니 다:

python 분포 도 그리 기 방향:
먼저 목록 에서 분포 도 x,y 축의 수 치 를 정의 한 다음 plt.plot()방법 을 사용 하면 분포 도 를 그 릴 수 있 습 니 다.
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기