濮阳杆衣贸易有限公司

主頁 > 知識庫 > matplotlib階梯圖的實(shí)現(xiàn)(step())

matplotlib階梯圖的實(shí)現(xiàn)(step())

熱門標(biāo)簽:舉辦過冬奧會(huì)的城市地圖標(biāo)注 400電話申請資格 地圖地圖標(biāo)注有嘆號 阿里電話機(jī)器人對話 qt百度地圖標(biāo)注 正安縣地圖標(biāo)注app 螳螂科技外呼系統(tǒng)怎么用 遼寧智能外呼系統(tǒng)需要多少錢 電銷機(jī)器人系統(tǒng)廠家鄭州

step函數(shù)概述

step函數(shù)用于繪制階梯圖。

根據(jù)源碼可知,step函數(shù)是對plot函數(shù)的輕量級封裝,很多概念和用法與plot函數(shù)非常相似。

def step(self, x, y, *args, where='pre', data=None, **kwargs):
 cbook._check_in_list(('pre', 'post', 'mid'), where=where)
 kwargs['drawstyle'] = 'steps-' + where
 return self.plot(x, y, *args, data=data, **kwargs)

step函數(shù)簽名:

matplotlib.pyplot.step(x, y, *args, where='pre', data=None, **kwargs)

step函數(shù)調(diào)用簽名:

step(x, y, [fmt], *, data=None, where='pre', **kwargs)
step(x, y, [fmt], x2, y2, [fmt2], ..., *, where='pre', **kwargs)

其中:

  • x:類數(shù)組結(jié)構(gòu),一維x軸坐標(biāo)序列。一般假設(shè)x軸坐標(biāo)均勻遞增。必備參數(shù)。
  • y:類數(shù)組結(jié)構(gòu),一維y軸坐標(biāo)序列。必備參數(shù)。
  • fmt:格式字符串,與plot函數(shù)的fmt參數(shù)類似??蛇x參數(shù)。官方建議只設(shè)置顏色格式。
  • data:可索引數(shù)據(jù),類似于plot函數(shù)??蛇x參數(shù)。
  • **kwargs:類似于plot函數(shù)。
  • where :設(shè)置階梯所在位置,取值范圍為{'pre', 'post', 'mid'},默認(rèn)值為'pre'。

 案例:使用step函數(shù)和plot函數(shù)演示不同where參數(shù)的效果

通過案例可知,step函數(shù)可以認(rèn)為是plot函數(shù)繪制階梯圖的一個(gè)特例。

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(14)
y = np.sin(x / 2)

plt.figure(figsize=(12,5))
plt.subplot(121)
plt.step(x, y + 2, label='pre (default)')
plt.plot(x, y + 2, 'o--', color='grey', alpha=0.3)

plt.step(x, y + 1, where='mid', label='mid')
plt.plot(x, y + 1, 'o--', color='grey', alpha=0.3)

plt.step(x, y, where='post', label='post')
plt.plot(x, y, 'o--', color='grey', alpha=0.3)

plt.grid(axis='x', color='0.95')
plt.legend(title='Parameter where:')
plt.title('plt.step(where=...)')

plt.subplot(122)
plt.plot(x, y + 2, drawstyle='steps', label='steps (=steps-pre)')
plt.plot(x, y + 2, 'o--', color='grey', alpha=0.3)

plt.plot(x, y + 1, drawstyle='steps-mid', label='steps-mid')
plt.plot(x, y + 1, 'o--', color='grey', alpha=0.3)

plt.plot(x, y, drawstyle='steps-post', label='steps-post')
plt.plot(x, y, 'o--', color='grey', alpha=0.3)

plt.grid(axis='x', color='0.95')
plt.legend(title='Parameter drawstyle:')
plt.title('plt.plot(drawstyle=...)')
plt.show()

到此這篇關(guān)于matplotlib階梯圖的實(shí)現(xiàn)(step())的文章就介紹到這了,更多相關(guān)matplotlib 階梯圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • python學(xué)習(xí)之使用Matplotlib畫實(shí)時(shí)的動(dòng)態(tài)折線圖的示例代碼
  • Matplotlib animation模塊實(shí)現(xiàn)動(dòng)態(tài)圖
  • matplotlib bar()實(shí)現(xiàn)多組數(shù)據(jù)并列柱狀圖通用簡便創(chuàng)建方法
  • matplotlib源碼解析標(biāo)題實(shí)現(xiàn)(窗口標(biāo)題,標(biāo)題,子圖標(biāo)題不同之間的差異)
  • matplotlib繪制正余弦曲線圖的實(shí)現(xiàn)
  • 詳解matplotlib繪圖樣式(style)初探
  • matplotlib更改窗口圖標(biāo)的方法示例
  • matplotlib繪制多子圖共享鼠標(biāo)光標(biāo)的方法示例
  • python使用matplotlib的savefig保存時(shí)圖片保存不完整的問題
  • matplotlib 畫動(dòng)態(tài)圖以及plt.ion()和plt.ioff()的使用詳解
  • matplotlib制作雷達(dá)圖報(bào)錯(cuò)ValueError的實(shí)現(xiàn)

標(biāo)簽:隨州 興安盟 合肥 阜新 信陽 昭通 濟(jì)源 淘寶好評回訪

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《matplotlib階梯圖的實(shí)現(xiàn)(step())》,本文關(guān)鍵詞  matplotlib,階梯,圖,的,實(shí)現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《matplotlib階梯圖的實(shí)現(xiàn)(step())》相關(guān)的同類信息!
  • 本頁收集關(guān)于matplotlib階梯圖的實(shí)現(xiàn)(step())的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    泸州市| 科技| 凤冈县| 报价| 宜兴市| 潍坊市| 芜湖县| 高青县| 蒲江县| 喀喇沁旗| 黄浦区| 阿拉尔市| 永嘉县| 荣昌县| 乡宁县| 英德市| 陇西县| 高淳县| 澄迈县| 白水县| 灵寿县| 砀山县| 湖北省| 沅江市| 来凤县| 瑞安市| 象山县| 太湖县| 南平市| 安庆市| 潞西市| 九江县| 女性| 南溪县| 罗源县| 中超| 竹溪县| 宜川县| 澎湖县| 抚松县| 中方县|