python繪制分布折線圖的示例
更新時(shí)間:2020年09月24日 11:32:31 作者:CuriousZero
這篇文章主要介紹了python繪制分布折線圖的示例代碼,幫助大家更好的利用python繪制圖像,感興趣的朋友可以了解下
用Python 繪制分布(折線)圖,使用的是 plot()函數(shù)。
一個(gè)簡(jiǎn)單的例子:
# 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()
結(jié)果:
以上就是python繪制分布折線圖的示例代碼的詳細(xì)內(nèi)容,更多關(guān)于python繪制分布折線圖的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
利用python為PostgreSQL的表自動(dòng)添加分區(qū)
這篇文章主要介紹了利用python為PostgreSQL的表自動(dòng)添加分區(qū),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01Python 使用元類type創(chuàng)建類對(duì)象常見應(yīng)用詳解
這篇文章主要介紹了Python 使用元類type創(chuàng)建類對(duì)象,結(jié)合實(shí)例形式詳細(xì)分析了Python元類的概念、功能及元類type創(chuàng)建類對(duì)象的常見應(yīng)用技巧,需要的朋友可以參考下2019-10-10Django框架登錄加上驗(yàn)證碼校驗(yàn)實(shí)現(xiàn)驗(yàn)證功能示例
這篇文章主要介紹了Django框架登錄加上驗(yàn)證碼校驗(yàn)實(shí)現(xiàn)驗(yàn)證功能,結(jié)合實(shí)例形式分析了Django框架基于Pillow模塊的圖形驗(yàn)證碼生成與使用相關(guān)操作技巧,需要的朋友可以參考下2019-05-05