
- Matplotlib 基礎
- Matplotlib - 首頁
- Matplotlib - 簡介
- Matplotlib - Vs Seaborn
- Matplotlib - 環境設定
- Matplotlib - Anaconda 發行版
- Matplotlib - Jupyter Notebook
- Matplotlib - Pyplot API
- Matplotlib - 簡單繪圖
- Matplotlib - 儲存圖形
- Matplotlib - 標記
- Matplotlib - 圖形
- Matplotlib - 樣式
- Matplotlib - 圖例
- Matplotlib - 顏色
- Matplotlib - 顏色圖
- Matplotlib - 顏色圖歸一化
- Matplotlib - 選擇顏色圖
- Matplotlib - 色標
- Matplotlib - 文字
- Matplotlib - 文字屬性
- Matplotlib - 子圖示題
- Matplotlib - 影像
- Matplotlib - 影像蒙版
- Matplotlib - 註釋
- Matplotlib - 箭頭
- Matplotlib - 字型
- Matplotlib - 什麼是字型?
- 全域性設定字型屬性
- Matplotlib - 字型索引
- Matplotlib - 字型屬性
- Matplotlib - 刻度
- Matplotlib - 線性和對數刻度
- Matplotlib - 對稱對數刻度和Logit刻度
- Matplotlib - LaTeX
- Matplotlib - 什麼是LaTeX?
- Matplotlib - 用於數學表示式的LaTeX
- Matplotlib - 註釋中的LaTeX文字格式化
- Matplotlib - PostScript
- 在註釋中啟用LaTeX渲染
- Matplotlib - 數學表示式
- Matplotlib - 動畫
- Matplotlib - 藝術家
- Matplotlib - 使用Cycler進行樣式設定
- Matplotlib - 路徑
- Matplotlib - 路徑效果
- Matplotlib - 變換
- Matplotlib - 刻度和刻度標籤
- Matplotlib - 弧度刻度
- Matplotlib - 日期刻度
- Matplotlib - 刻度格式化程式
- Matplotlib - 刻度定位器
- Matplotlib - 基本單位
- Matplotlib - 自動縮放
- Matplotlib - 反轉軸
- Matplotlib - 對數軸
- Matplotlib - Symlog
- Matplotlib - 單位處理
- Matplotlib - 帶單位的橢圓
- Matplotlib - 脊柱
- Matplotlib - 軸範圍
- Matplotlib - 軸刻度
- Matplotlib - 軸刻度
- Matplotlib - 格式化軸
- Matplotlib - Axes 類
- Matplotlib - 雙軸
- Matplotlib - Figure 類
- Matplotlib - 多圖
- Matplotlib - 網格
- Matplotlib - 面向物件介面
- Matplotlib - PyLab 模組
- Matplotlib - Subplots() 函式
- Matplotlib - Subplot2grid() 函式
- Matplotlib - 固定藝術家
- Matplotlib - 手動等值線
- Matplotlib - 座標報告
- Matplotlib - AGG 過濾器
- Matplotlib - 帶狀框
- Matplotlib - 填充螺旋
- Matplotlib - Findobj 演示
- Matplotlib - 超連結
- Matplotlib - 影像縮圖
- Matplotlib - 使用關鍵字繪圖
- Matplotlib - 建立徽標
- Matplotlib - 多頁 PDF
- Matplotlib - 多處理
- Matplotlib - 列印標準輸出
- Matplotlib - 複合路徑
- Matplotlib - Sankey 類
- Matplotlib - 帶 EEG 的 MRI
- Matplotlib - 樣式表
- Matplotlib - 背景顏色
- Matplotlib - Basemap
- Matplotlib 事件處理
- Matplotlib - 事件處理
- Matplotlib - 關閉事件
- Matplotlib - 滑鼠移動
- Matplotlib - 點選事件
- Matplotlib - 滾動事件
- Matplotlib - 按鍵事件
- Matplotlib - 選擇事件
- Matplotlib - 觀察鏡
- Matplotlib - 路徑編輯器
- Matplotlib - 多邊形編輯器
- Matplotlib - 定時器
- Matplotlib - Viewlims
- Matplotlib - 縮放視窗
- Matplotlib 小部件
- Matplotlib - 游標小部件
- Matplotlib - 帶註釋的游標
- Matplotlib - 按鈕小部件
- Matplotlib - 複選框
- Matplotlib - 套索選擇器
- Matplotlib - 選單小部件
- Matplotlib - 滑鼠游標
- Matplotlib - 多游標
- Matplotlib - 多邊形選擇器
- Matplotlib - 單選按鈕
- Matplotlib - RangeSlider
- Matplotlib - 矩形選擇器
- Matplotlib - 橢圓選擇器
- Matplotlib - 滑塊小部件
- Matplotlib - 跨度選擇器
- Matplotlib - 文字框
- Matplotlib 繪圖
- Matplotlib - 條形圖
- Matplotlib - 直方圖
- Matplotlib - 餅圖
- Matplotlib - 散點圖
- Matplotlib - 箱線圖
- Matplotlib - 小提琴圖
- Matplotlib - 等值線圖
- Matplotlib - 3D 繪圖
- Matplotlib - 3D 等值線
- Matplotlib - 3D 線框圖
- Matplotlib - 3D 曲面圖
- Matplotlib - Quiver 圖
- Matplotlib 有用資源
- Matplotlib - 快速指南
- Matplotlib - 有用資源
- Matplotlib - 討論
Matplotlib - 對稱對數刻度和Logit刻度
對稱對數刻度
對稱對數刻度類似於對數刻度。它通常縮寫為symlog,這是一種用於在軸上表示資料的刻度型別,其中值使用對數間隔對稱分佈在零周圍。它為正值和負值提供了類似對數的刻度,同時容納零。
要在 x 軸和 y 軸上應用對稱對數刻度,我們必須分別使用plt.xscale('symlog')和plt.yscale('symlog')。
對稱對數刻度的特徵
對稱對數刻度具有以下特徵。
- 對稱行為 - 對數表示正值和負值,同時處理零。
- 零附近線性 - 刻度在零附近一定範圍內(linthresh)是線性的,然後過渡到對數行為。
對稱對數刻度的引數
linthresh - 線性閾值,用於確定零周圍刻度線性行為的範圍,然後過渡到對數刻度。
何時使用對稱對數刻度
- 零附近的的資料 - 適用於包含以零為中心且具有廣泛正值和負值範圍的值的資料集。
- 避免對稱偏差 - 當需要對正值和負值進行對稱表示而不對任一側產生偏差時。
對稱對數刻度的重要性
對稱對數刻度提供了一種類似對數的刻度,可以容納正值和負值,使其可用於視覺化圍繞零具有平衡分佈的資料集。
它還有助於突出零附近的較小變化,同時容納較大的值而不會歪曲表示。
使用對稱對數刻度的繪圖
在此圖中,我們透過使用plt.yscale('symlog', linthresh=0.01)在 y 軸上建立對稱對數刻度。
示例
import matplotlib.pyplot as plt import numpy as np # Generating data for a sine wave with values around zero x = np.linspace(-10, 10, 500) y = np.sin(x) # Creating a plot with a symmetrical logarithmic scale for the y-axis plt.plot(x, y) # Set symmetrical logarithmic scale for the y-axis plt.yscale('symlog', linthresh=0.01) plt.xlabel('X-axis') plt.ylabel('Y-axis (symlog scale)') plt.title('Symmetrical Logarithmic Scale') plt.show()
輸出

在 Matplotlib 中使用對稱對數刻度可以視覺化包含零附近的值的資料集,方法是能夠有效地表示和分析對稱分佈的資料。調整線性閾值 (linthresh) 引數對於確定刻度在零附近線性行為的範圍(然後過渡到對數刻度)至關重要。
Logit 刻度
Logit 刻度是一種專門的刻度型別,用於在軸上表示資料,其中值限制在 0 和 1 之間。它專為在此範圍內存在的資料而設計,通常在機率或表示機率的值中遇到。
設定刻度
plt.xscale()和plt.yscale()函式可分別用於設定 x 軸和 y 軸的刻度。
Logit 刻度的特徵
以下是 Logit 刻度的特徵。
- 約束資料 - 專用於 0 和 1 之間的資料。
- 變換 - 利用 logit 函式將值從標準邏輯分佈對映。
何時使用 Logit 刻度
機率資料 - 適用於視覺化機率或表示機率的值,尤其是在處理邏輯迴歸或邏輯模型時。
0 到 1 範圍內的資料 - 專為 0 到 1 區間內的資料而設計。
Logit 刻度的重要性
- Logit 刻度有助於視覺化和分析表示機率或具有機率解釋的資料。
- 它還有助於理解和視覺化機率相關資料的變換。
使用 Logit 刻度的繪圖
在此圖中,我們在 x 軸和 y 軸上建立 Logit 刻度。
示例
import matplotlib.pyplot as plt import numpy as np # Generating data within the 0 to 1 range x = np.linspace(0.001, 0.999, 100) y = np.log(x / (1 - x)) # Creating a plot with a logit scale for the x-axis plt.plot(x, y) plt.xscale('logit') # Set logit scale for the x-axis plt.xlabel('X-axis (logit scale)') plt.ylabel('Y-axis') plt.title('Logit Scale') plt.show()
輸出

瞭解並選擇適合繪圖的刻度對於準確表示基礎資料並確保在視覺化中有效傳達模式和趨勢非常重要。
在 Matplotlib 庫中按名稱繪製 yscale 類線性、對數、logit 和 symlog。
在此圖中,我們按名稱繪製 yscale 類線性、對數、logit 和 symlog。
示例
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True y = np.random.normal(loc=0.5, scale=0.4, size=1000) y = y[(y > 0) & (y < 1)] y.sort() x = np.arange(len(y)) # linear plt.subplot(221) plt.plot(x, y) plt.yscale('linear') plt.title('linear') # log plt.subplot(222) plt.plot(x, y) plt.yscale('log') plt.title('log') # symmetric log plt.subplot(223) plt.plot(x, y - y.mean()) plt.yscale('symlog', linthresh=0.01) plt.title('symlog') # logit plt.subplot(224) plt.plot(x, y) plt.yscale('logit') plt.title('logit') plt.show()
輸出
