新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
python畫出分布圖的方法-創(chuàng)新互聯(lián)
創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!
小編給大家分享一下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軸標(biāo)簽 plt.xlabel("clusters") plt.ylabel("number of reviews") # Y軸標(biāo)簽 plt.title("A simple plot") # 標(biāo)題 plt.show()
效果如下:
python畫分布圖的思路:
先在列表中定義分布圖x、y軸的數(shù)值,然后使用plt.plot()方法即可將分布圖繪制出來。
看完了這篇文章,相信你對python畫出分布圖的方法有了一定的了解,想了解更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道,感謝各位的閱讀!
分享名稱:python畫出分布圖的方法-創(chuàng)新互聯(lián)
文章網(wǎng)址:http://fisionsoft.com.cn/article/dihhgi.html