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ū),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01
python 文件常用操作demo(讀寫 打開(kāi)方式)
這篇文章主要為大家介紹了python 文件常用操作demo(讀寫 打開(kāi)方式)及使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03
Python 使用元類type創(chuàng)建類對(duì)象常見(jiàn)應(yīng)用詳解
這篇文章主要介紹了Python 使用元類type創(chuàng)建類對(duì)象,結(jié)合實(shí)例形式詳細(xì)分析了Python元類的概念、功能及元類type創(chuàng)建類對(duì)象的常見(jiàn)應(yīng)用技巧,需要的朋友可以參考下2019-10-10
python處理“”開(kāi)頭加數(shù)字的html字符方法
在本篇文章里小編給大家整理了關(guān)于python如何處理“&#”開(kāi)頭加數(shù)字的html字符的相關(guān)知識(shí)點(diǎn)總結(jié),有興趣的朋友們學(xué)習(xí)下。2019-06-06
Django框架登錄加上驗(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

