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通過(guò)dxfgrabber庫(kù)實(shí)現(xiàn)獲取CAD信息
dxfgrabber?是一個(gè)?Python?庫(kù),用于讀取和解析?AutoCAD?DXF(Drawing?Exchange?Format)文件,本文就來(lái)教教大家如何利用dxfgrabber庫(kù)實(shí)現(xiàn)獲取CAD信息吧2023-06-06
簡(jiǎn)單的Apache+FastCGI+Django配置指南
這篇文章主要介紹了簡(jiǎn)單的Apache+FastCGI+Django配置指南,這也是Python上最流行的web框架Django的最流行搭配環(huán)境:)需要的朋友可以參考下2015-07-07
Python?for循環(huán)詳細(xì)講解(附代碼實(shí)例)
這篇文章主要給大家介紹了關(guān)于Python?for循環(huán)詳細(xì)講解的相關(guān)資料,在Python中,for循環(huán)是一種常用的控制結(jié)構(gòu),用于遍歷序列(如列表、元組、字符串等)中的元素,需要的朋友可以參考下2024-03-03
pytorch動(dòng)態(tài)神經(jīng)網(wǎng)絡(luò)(擬合)實(shí)現(xiàn)
這篇文章主要介紹了pytorch動(dòng)態(tài)神經(jīng)網(wǎng)絡(luò)(擬合)實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
Python實(shí)現(xiàn)switch/case語(yǔ)句
與Java、C\C++等語(yǔ)言不同,Python中是不提供switch/case語(yǔ)句的,這一點(diǎn)讓我感覺(jué)到很奇怪。我們可以通過(guò)如下幾種方法來(lái)實(shí)現(xiàn)switch/case語(yǔ)句2021-08-08

