網站首頁 編程語言 正文
用法:
matplotlib.pyplot.stem(*args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, label=None, use_line_collection=True, orientation='vertical', data=None)
參數說明
參數 | ? |
---|---|
*args | x,y,x—棉棒的x軸基線的取值范圍,y—棉棒的長度 |
linefmt | 棉棒的樣式,{‘-’,’–’,’:’,’-.’},包括指定顏色等 |
markerfmt | 棉棒末端的樣式 |
basefmt | 指定基線的樣式 |
bottom | 默認值為0,極限的y/x的位置,取決于方向 |
label | 用于標簽 |
use_line_collection | 默認值是True,如果為True,棉棒的莖線存儲并繪制為線集合,而不是單獨的線,這將顯著提高性能,而不是單獨的線 |
orientation | 控制方向,默認為垂直(True). |
案例
參數
x,y
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0.1, 2 * np.pi, 41) y = np.exp(np.sin(x)) plt.stem(x, y) plt.show()
linefmtlinefmt用來指定棉棒的顏色和樣式等
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0.1,2 * np.pi, 41) y = np.exp(np.sin(x)) fit, axs = plt.subplots(nrows=2, ncols=2, figsize=(14,7)) axs[0,0].set_title("linefmt='-',color='green'") axs[0,0] = axs[0,0].stem(x,y,linefmt='g-') axs[0,1].set_title("linefmt='-.', color='blue'") axs[0,1] = axs[0,1].stem(x,y,linefmt='b-.') axs[1,0].set_title("linefmt=':', color='red'") axs[1,0] = axs[1,0].stem(x,y,linefmt='r:') axs[1,1].set_title("linefmt='--', color='p'") axs[1,1] = axs[1,1].stem(x,y,linefmt='o--') plt.show()
basefmt
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0.1,2 * np.pi, 41) y = np.exp(np.sin(x)) fit, axs = plt.subplots(nrows=2, ncols=1, figsize=(14,7)) axs[0].set_title("basefmt='-',color='C2'") axs[0] = axs[0].stem(x,y,linefmt='b--',basefmt='C2--') axs[1].set_title("basefmt='-.', color='C1'") axs[1] = axs[1].stem(x,y,linefmt='b-.',basefmt='C1-.') plt.show()
bottom
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0.1,2 * np.pi, 41) y = np.exp(np.sin(x)) fit, axs = plt.subplots(nrows=1, ncols=2, figsize=(14,7)) axs[0].set_title("bottom") axs[0].stem(x,y,linefmt='grey',markerfmt='D',bottom=1.1) axs[1].set_title('no bottom') axs[1].stem(x,y,linefmt='grey',markerfmt='D') plt.show()
案例
import numpy as np import matplotlib.pyplot as plt # 生成模擬數據集 x=np.linspace(0,10,20) y=np.random.randn(20) # 繪制棉棒圖 markerline, stemlines, baseline = plt.stem(x,y,linefmt='-',markerfmt='o',basefmt='--',label='TestStem') # 可單獨設置棉棒末端,棉棒連線以及基線的屬性 plt.setp(markerline, color='k')#將棉棒末端設置為黑色 plt.legend() plt.show()
總結
原文鏈接:https://blog.csdn.net/KIKI_ZSH/article/details/123659896
相關推薦
- 2024-03-19 Shell腳本中的條件測試命令簡介
- 2022-05-17 【go】解決“dial tcp 142.251.42.241:443: connect: conne
- 2022-10-24 React中的生命周期和子組件_React
- 2023-07-28 dialog 對話框垂直居中
- 2023-03-05 Suspend函數與回調的互相轉換示例詳解_Android
- 2022-11-15 python運行cmd命令行的3種方法總結_python
- 2024-03-22 解決springboot錯誤頁面exception、message取值為空
- 2022-07-10 CSS解決未知高度垂直居中
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支