rsplotlib 0.2.6__tar.gz → 0.2.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/.github/workflows/ci.yml +6 -7
  2. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/.gitignore +2 -1
  3. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/Cargo.lock +5 -3
  4. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/Cargo.toml +5 -1
  5. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/PKG-INFO +113 -27
  6. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/README.md +90 -3
  7. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/README_zh.md +112 -26
  8. rsplotlib-0.2.9/RELEASE_NOTES.md +162 -0
  9. rsplotlib-0.2.9/RELEASE_NOTES_zh.md +145 -0
  10. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/pyproject.toml +1 -1
  11. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/__init__.py +1 -1
  12. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/pyplot.py +166 -44
  13. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/core/elements.rs +10 -0
  14. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes.rs +389 -53
  15. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_bounds.rs +54 -25
  16. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_render_elements.rs +532 -82
  17. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axis.rs +76 -6
  18. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/figure.rs +50 -30
  19. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/lib.rs +112 -0
  20. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/utils/font_stack.rs +51 -5
  21. rsplotlib-0.2.9/src/utils/glyph_cache.rs +229 -0
  22. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/utils/mod.rs +2 -0
  23. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/utils/pyfuncs.rs +45 -3
  24. rsplotlib-0.2.9/src/utils/rgb_backend.rs +232 -0
  25. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/tutorial.html +482 -95
  26. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/.github/workflows/release.yml +0 -0
  27. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/.github/workflows/rust.yml +0 -0
  28. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/LICENSE +0 -0
  29. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/build_wheel.sh +0 -0
  30. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/ci/smoke_test.py +0 -0
  31. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/_font_resolver.py +0 -0
  32. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/colors.py +0 -0
  33. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/core/__init__.py +0 -0
  34. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/core/api.py +0 -0
  35. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/dates.py +0 -0
  36. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/figure/__init__.py +0 -0
  37. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/figure/_defaults.py +0 -0
  38. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/gridspec.py +0 -0
  39. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/layout/__init__.py +0 -0
  40. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/layout/gridspec.py +0 -0
  41. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/pylab.py +0 -0
  42. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/ticker.py +0 -0
  43. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/ticks/__init__.py +0 -0
  44. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/ticks/ticker.py +0 -0
  45. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/utils/__init__.py +0 -0
  46. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/utils/_font_resolver.py +0 -0
  47. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/utils/_rcparams.py +0 -0
  48. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/python/rsplotlib/utils/style.py +0 -0
  49. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/rust-toolchain.toml +0 -0
  50. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/core/colormap.rs +0 -0
  51. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/core/colors.rs +0 -0
  52. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/core/marker.rs +0 -0
  53. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/core/mod.rs +0 -0
  54. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_colorbar.rs +0 -0
  55. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_grid.rs +0 -0
  56. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_legend.rs +0 -0
  57. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_mesh.rs +0 -0
  58. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_secondary.rs +0 -0
  59. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/axes_title.rs +0 -0
  60. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/figure/mod.rs +0 -0
  61. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/layout/gridspec.rs +0 -0
  62. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/layout/mod.rs +0 -0
  63. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/ticks/mod.rs +0 -0
  64. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/ticks/ticker.rs +0 -0
  65. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/utils/font_resolver.rs +0 -0
  66. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/utils/mathtext.rs +0 -0
  67. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/src/utils/style.rs +0 -0
  68. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/tutorial.css +0 -0
  69. {rsplotlib-0.2.6 → rsplotlib-0.2.9}/tutorial.js +0 -0
@@ -14,21 +14,20 @@ concurrency:
14
14
  permissions:
15
15
  contents: read
16
16
 
17
+ env:
18
+ CARGO_TERM_COLOR: always
19
+ RUST_BACKTRACE: 1
20
+
17
21
  jobs:
18
22
  test:
19
23
  name: Test (${{ matrix.os }}, py${{ matrix.python-version }})
20
24
  runs-on: ${{ matrix.os }}
21
25
  strategy:
22
26
  fail-fast: false
27
+ # 覆盖最低支持版本 3.10、当前主力 3.13 与最新 3.14,三大平台全跑。
23
28
  matrix:
24
29
  os: [ubuntu-latest, windows-latest, macos-latest]
25
30
  python-version: ["3.10", "3.13", "3.14"]
26
- # 补测最低支持版本 3.8;macOS(arm64) 对 3.8 支持不稳定,故仅在 Linux/Windows 上测。
27
- include:
28
- - os: ubuntu-latest
29
- python-version: "3.10"
30
- - os: windows-latest
31
- python-version: "3.10"
32
31
  steps:
33
32
  - uses: actions/checkout@v4
34
33
 
@@ -79,4 +78,4 @@ jobs:
79
78
  run: cargo fmt --all -- --check
80
79
 
81
80
  - name: Run clippy
82
- run: cargo clippy -- -D warnings
81
+ run: cargo clippy --all-targets -- -D warnings
@@ -32,7 +32,8 @@ test/
32
32
  test*.py
33
33
  *.png
34
34
  main*.py
35
- debug.txt
35
+ .trae/
36
+ debug.md
36
37
  out/
37
38
  wheelhouse/
38
39
  N237S NB.csv
@@ -50,9 +50,9 @@ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
50
50
 
51
51
  [[package]]
52
52
  name = "bytemuck"
53
- version = "1.25.0"
53
+ version = "1.25.1"
54
54
  source = "registry+https://github.com/rust-lang/crates.io-index"
55
- checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec"
55
+ checksum = "d6aedf8ae72766347502cf3cb4f41cf5e9cc37d28bee90f1fdaaae15f9cf9424"
56
56
 
57
57
  [[package]]
58
58
  name = "byteorder"
@@ -417,12 +417,14 @@ dependencies = [
417
417
 
418
418
  [[package]]
419
419
  name = "rsplotlib"
420
- version = "0.2.6"
420
+ version = "0.2.9"
421
421
  dependencies = [
422
+ "ab_glyph",
422
423
  "jpeg-decoder",
423
424
  "jpeg-encoder",
424
425
  "owned_ttf_parser",
425
426
  "plotters",
427
+ "plotters-backend",
426
428
  "png 0.18.1",
427
429
  "pyo3",
428
430
  ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rsplotlib"
3
- version = "0.2.6"
3
+ version = "0.2.9"
4
4
  edition = "2024"
5
5
  readme = "README.md"
6
6
 
@@ -15,6 +15,10 @@ png = "0.18.1"
15
15
  owned_ttf_parser = "0.25.1"
16
16
  jpeg-encoder = "0.7.0"
17
17
  jpeg-decoder = "0.3.2"
18
+ # 与 plotters 0.3.7 相同版本的 ab_glyph / plotters-backend(均已在 Cargo.lock 锁定,
19
+ # 不引入新下载):glyph 缓存需直接引用 ab_glyph 光栅化器与后端 trait 类型。
20
+ ab_glyph = "0.2.32"
21
+ plotters-backend = "0.3.7"
18
22
 
19
23
  [profile.release]
20
24
  lto = "fat"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rsplotlib
3
- Version: 0.2.6
3
+ Version: 0.2.9
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3 :: Only
@@ -71,6 +71,21 @@ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
71
71
  - **统计图表**:直方图、箱线图、饼图、误差棒图、茎叶图、阶梯图
72
72
  - **高级图表**:堆叠面积图、热力图/图像显示、填充区域图
73
73
 
74
+ ### 颜色映射与颜色条
75
+
76
+ - **50+ 内置颜色映射**:`viridis`、`plasma`、`inferno`、`magma`、`cividis`、`jet`、`coolwarm`、`RdBu`、`Blues`、`Greens`、`Reds`、`hot`、`cool`、`gray`、`terrain`、`twilight` 等,任意名称加 `_r` 后缀即可反转(如 `viridis_r`)
77
+ - **颜色条 Colorbar**:`plt.colorbar()` / `fig.colorbar()`,Rust 渲染,支持 `location`、`orientation`、`shrink`、`aspect`、`pad`、`fraction`、`label`、`extend`、`ticks`、`format`
78
+ - **颜色归一化**:`LogNorm` / `Normalize`(来自 `rsplotlib.colors`),通过 `norm=` 参数使用
79
+
80
+ ### 图像输入 / 输出
81
+
82
+ - **`imshow`**:支持二维数据(经颜色映射,可用对数归一化)与 RGB/RGBA 图像,支持 `alpha`、`origin`、`interpolation` 控制
83
+ - **`imread` / `imsave`**:读写 PNG/JPEG 图像
84
+
85
+ ### 数学公式渲染
86
+
87
+ - **LaTeX 风格 `$...$`**:上下标、`\frac`、`\sqrt[n]{}`、希腊字母、重音与字体样式命令,在标题、轴标签、`text`、`annotate`、图例、柱状图标签中生效
88
+
74
89
  ### 辅助元素
75
90
 
76
91
  - **参考线**:水平参考线 (`axhline`)、垂直参考线 (`axvline`)
@@ -357,24 +372,27 @@ plt.savefig('module_level.png')
357
372
 
358
373
  ### 绘图函数
359
374
 
360
- | 函数 | 说明 | 模块级接口 | Axes 接口 |
361
- | ---------------- | --------------------------- | ---------- | --------- |
362
- | `plot()` | 折线图 | ✅ | ✅ |
363
- | `scatter()` | 散点图(支持颜色/大小数组) | ✅ | ✅ |
364
- | `bar()` | 柱状图 | ✅ | ✅ |
365
- | `barh()` | 水平柱状图 | ✅ | ✅ |
366
- | `hist()` | 直方图 | ✅ | ✅ |
367
- | `pie()` | 饼图 | ✅ | ✅ |
368
- | `boxplot()` | 箱线图 | ✅ | ✅ |
369
- | `fill_between()` | 曲线间填充 | ✅ | ✅ |
370
- | `errorbar()` | 误差棒图 | ✅ | ✅ |
371
- | `stem()` | 茎叶图 | ✅ | ✅ |
372
- | `step()` | 阶梯图 | ✅ | ✅ |
373
- | `imshow()` | 图像/热力图 | ✅ | ✅ |
374
- | `stackplot()` | 堆叠面积图 | ✅ | ✅ |
375
- | `semilogx()` | x 轴对数坐标折线图 | ✅ | ✅ |
376
- | `semilogy()` | y 轴对数坐标折线图 | ✅ | ✅ |
377
- | `loglog()` | 双对数坐标折线图 | ✅ | ✅ |
375
+ | 函数 | 说明 | 模块级接口 | Axes 接口 |
376
+ | ---------------- | --------------------------- | ------------- | --------- |
377
+ | `plot()` | 折线图 | ✅ | ✅ |
378
+ | `scatter()` | 散点图(支持颜色/大小数组) | ✅ | ✅ |
379
+ | `bar()` | 柱状图 | ✅ | ✅ |
380
+ | `barh()` | 水平柱状图 | ✅ | ✅ |
381
+ | `hist()` | 直方图 | ✅ | ✅ |
382
+ | `pie()` | 饼图 | ✅ | ✅ |
383
+ | `boxplot()` | 箱线图 | ✅ | ✅ |
384
+ | `fill_between()` | 曲线间填充 | ✅ | ✅ |
385
+ | `errorbar()` | 误差棒图 | ✅ | ✅ |
386
+ | `stem()` | 茎叶图 | ✅ | ✅ |
387
+ | `step()` | 阶梯图 | ✅ | ✅ |
388
+ | `imshow()` | 图像/热力图 | ✅ | ✅ |
389
+ | `stackplot()` | 堆叠面积图 | ✅ | ✅ |
390
+ | `semilogx()` | x 轴对数坐标折线图 | ✅ | ✅ |
391
+ | `semilogy()` | y 轴对数坐标折线图 | ✅ | ✅ |
392
+ | `loglog()` | 双对数坐标折线图 | ✅ | ✅ |
393
+ | `colorbar()` | 为 mappable 添加颜色条 | ✅(plt/fig) | ❌ |
394
+ | `imread()` | 读取 PNG/JPEG 图像为数组 | ✅ | ❌ |
395
+ | `imsave()` | 将数组写出为 PNG/JPEG | ✅ | ❌ |
378
396
 
379
397
  ### 辅助元素
380
398
 
@@ -556,6 +574,66 @@ ax.vlines(x, color=None, linestyle=None, linewidth=None)
556
574
 
557
575
  - `y` / `x` (list/array): 位置列表
558
576
 
577
+ ### Axes.imshow / plt.imshow
578
+
579
+ 将二维数据显示为热力图,或渲染 RGB/RGBA 图像。
580
+
581
+ ```python
582
+ ax.imshow(x, cmap=None, norm=None, aspect=None, interpolation=None,
583
+ alpha=None, vmin=None, vmax=None, origin=None, extent=None)
584
+ ```
585
+
586
+ **参数:**
587
+
588
+ - `x` (二维数组或 HxWx3/4 图像): 标量场或 RGB(A) 图像
589
+ - `cmap` (str): 二维数据的颜色映射名(默认 `'viridis'`),加 `_r` 反转
590
+ - `norm` (`Normalize` / `LogNorm` / `'linear'` / `'log'`): 数值到颜色的映射
591
+ - `interpolation` (str): `'none'` / `'nearest'` 为块状缩放,其余为平滑模式
592
+ - `origin` (str): `'upper'`(默认)或 `'lower'`
593
+ - `vmin` / `vmax` (float): 数值范围裁剪;`alpha` (float): 不透明度
594
+ - 注意:`extent` 为兼容签名而接受,但当前被忽略
595
+
596
+ ```python
597
+ im = ax.imshow([[1, 2], [3, 4]], cmap='plasma', origin='lower')
598
+ ```
599
+
600
+ ### colorbar
601
+
602
+ 为 mappable(如 `imshow` / `scatter` 的返回值)添加颜色条。
603
+
604
+ ```python
605
+ plt.colorbar(mappable=None, ax=None, **kwargs)
606
+ fig.colorbar(mappable=None, ax=None, **kwargs)
607
+ ```
608
+
609
+ **生效的关键字参数:** `location`、`orientation`、`shrink`、`aspect`、`pad`、
610
+ `fraction`、`label`、`extend`、`ticks`、`format`。其余 matplotlib 关键字虽被接受,
611
+ 但当前不生效。
612
+
613
+ ```python
614
+ im = plt.imshow([[1, 2], [3, 4]], cmap='viridis')
615
+ plt.colorbar(im, label='数值', shrink=0.8)
616
+ ```
617
+
618
+ ### 颜色归一化(LogNorm)
619
+
620
+ ```python
621
+ from rsplotlib.colors import LogNorm
622
+ plt.imshow(data, cmap='viridis', norm=LogNorm())
623
+ plt.colorbar()
624
+ ```
625
+
626
+ ### 数学公式(`$...$`)
627
+
628
+ 所有承载文本的接口都支持美元符号之间的 LaTeX 风格公式,包括标题、轴标签、
629
+ `text`、`annotate`、图例标签与柱状图标签。
630
+
631
+ ```python
632
+ plt.title(r'$\alpha^2 + \frac{1}{2}\sqrt{x}$')
633
+ ```
634
+
635
+ 支持:上下标、`\frac`、`\sqrt[n]{}`、希腊字母、重音与字体样式命令。
636
+
559
637
  ---
560
638
 
561
639
  ## 性能优势
@@ -583,13 +661,17 @@ rsplotlib 在架构设计上通过"分层下沉"策略实现性能优化:
583
661
 
584
662
  ### 性能关键路径下沉到 Rust
585
663
 
586
- | 功能 | 传统实现 | rsplotlib 实现 |
587
- | --------------------------- | ----------------------------------- | ------------------------------- |
588
- | `scatter(c=colors)` | Python 层遍历每个点 | Rust 层 `ScatterMulti` 统一渲染 |
589
- | `scatter(s=sizes)` | Python 层遍历每个点 | Rust 层统一大小数组处理 |
590
- | `hlines([y1, y2, y3, ...])` | Python `for` 循环多次调用 `axhline` | Rust 层单次调用批量处理 |
591
- | `vlines([x1, x2, x3, ...])` | Python `for` 循环多次调用 `axvline` | Rust 层单次调用批量处理 |
592
- | `savefig(dpi=300)` | 无 DPI 支持 / Python 层缩放 | Rust 层直接写入 PNG DPI 元数据 |
664
+ | 功能 | 传统实现 | rsplotlib 实现 |
665
+ | -------------------------------- | ----------------------------------- | ------------------------------- |
666
+ | `scatter(c=colors)` | Python 层遍历每个点 | Rust 层 `ScatterMulti` 统一渲染 |
667
+ | `scatter(s=sizes)` | Python 层遍历每个点 | Rust 层统一大小数组处理 |
668
+ | `hlines([y1, y2, y3, ...])` | Python `for` 循环多次调用 `axhline` | Rust 层单次调用批量处理 |
669
+ | `vlines([x1, x2, x3, ...])` | Python `for` 循环多次调用 `axvline` | Rust 层单次调用批量处理 |
670
+ | `savefig(dpi=300)` | 无 DPI 支持 / Python 层缩放 | Rust 层直接写入 PNG DPI 元数据 |
671
+ | `hist()` / `boxplot()`(大数据) | Python 层物化每个数值 | 零拷贝缓冲区下沉到 Rust |
672
+ | 百万级点折线 | 渲染每一段线段 | 自动 min/max(M4)抽稀 |
673
+ | 大图 `imshow` | 单线程逐像素 | 多线程按行渲染 |
674
+ | 重复文本渲染 | 每个字形重复栅格化 | 按 (字体, 字符, 字号) 缓存字形 |
593
675
 
594
676
  ### 为什么选择 Rust + Python 混合架构
595
677
 
@@ -718,6 +800,9 @@ def axhspan(ymin, ymax, **kwargs):
718
800
  - 当前版本不支持 3D 绘图
719
801
  - 不支持动画/交互式图表
720
802
  - `contour` / `violinplot` / `hexbin` 为占位实现
803
+ - `imshow(extent=...)` 为兼容签名而接受,但当前被忽略
804
+ - `colorbar()` 仅部分 matplotlib 关键字生效(见 [colorbar](#colorbar))
805
+ - `data=` 当前仅 `scatter` 支持(`plot` 不支持)
721
806
 
722
807
  ---
723
808
 
@@ -775,8 +860,9 @@ MIT License — 详见 [LICENSE](LICENSE) 文件。
775
860
  ## 相关链接
776
861
 
777
862
  - **GitHub**: https://github.com/YJ-Niu/rsplotlib
863
+ - **发行说明**: [RELEASE_NOTES_zh.md](RELEASE_NOTES_zh.md)
778
864
 
779
865
  ---
780
866
 
781
- _最后更新:2026-07-03 · 版本 v0.1.9_
867
+ _最后更新:2026-07-12 · 版本 v0.2.9_
782
868
 
@@ -48,6 +48,21 @@
48
48
  - **Statistical Charts**: Histograms, box plots, pie charts, error bars, stem plots, step plots
49
49
  - **Advanced Charts**: Stacked area plots, heatmap/image display, fill-between regions
50
50
 
51
+ ### Colormaps & Colorbar
52
+
53
+ - **50+ Built-in Colormaps**: `viridis`, `plasma`, `inferno`, `magma`, `cividis`, `jet`, `coolwarm`, `RdBu`, `Blues`, `Greens`, `Reds`, `hot`, `cool`, `gray`, `terrain`, `twilight`, and more - any name reversible with a `_r` suffix (e.g. `viridis_r`)
54
+ - **Colorbar**: `plt.colorbar()` / `fig.colorbar()`, Rust-rendered, with `location`, `orientation`, `shrink`, `aspect`, `pad`, `fraction`, `label`, `extend`, `ticks`, `format`
55
+ - **Color Normalization**: `LogNorm` / `Normalize` (from `rsplotlib.colors`) via the `norm=` argument
56
+
57
+ ### Image Input / Output
58
+
59
+ - **`imshow`**: 2D data (via colormap, log-norm capable) and RGB/RGBA images, with `alpha`, `origin`, and `interpolation` control
60
+ - **`imread` / `imsave`**: read and write PNG/JPEG images
61
+
62
+ ### Math Text Rendering
63
+
64
+ - **LaTeX-style `$...$`**: superscripts/subscripts, `\frac`, `\sqrt[n]{}`, Greek letters, accents, and font-style commands - active in titles, axis labels, `text`, `annotate`, legend, and bar labels
65
+
51
66
  ### Annotation & Reference Elements
52
67
 
53
68
  - **Reference Lines**: Horizontal (`axhline`), vertical (`axvline`)
@@ -352,6 +367,9 @@ plt.savefig('module_level.png')
352
367
  | `semilogx()` | X-axis log-scale line plot | Yes | Yes |
353
368
  | `semilogy()` | Y-axis log-scale line plot | Yes | Yes |
354
369
  | `loglog()` | Log-log scale line plot | Yes | Yes |
370
+ | `colorbar()` | Colorbar for a mappable | Yes (plt/fig)| No |
371
+ | `imread()` | Read a PNG/JPEG image into an array | Yes | No |
372
+ | `imsave()` | Write an array to PNG/JPEG | Yes | No |
355
373
 
356
374
  ### Annotation Elements
357
375
 
@@ -536,6 +554,67 @@ ax.vlines(x, color=None, linestyle=None, linewidth=None)
536
554
 
537
555
  - `y` / `x` (list/array): Position list
538
556
 
557
+ ### Axes.imshow / plt.imshow
558
+
559
+ Display 2D data as a heatmap or render an RGB/RGBA image.
560
+
561
+ ```python
562
+ ax.imshow(x, cmap=None, norm=None, aspect=None, interpolation=None,
563
+ alpha=None, vmin=None, vmax=None, origin=None, extent=None)
564
+ ```
565
+
566
+ **Parameters:**
567
+
568
+ - `x` (2D array or HxWx3/4 image): scalar field or RGB(A) image
569
+ - `cmap` (str): colormap name for 2D data (default `'viridis'`); append `_r` to reverse
570
+ - `norm` (`Normalize` / `LogNorm` / `'linear'` / `'log'`): value-to-color mapping
571
+ - `interpolation` (str): `'none'` / `'nearest'` for block scaling, or a smooth mode
572
+ - `origin` (str): `'upper'` (default) or `'lower'`
573
+ - `vmin` / `vmax` (float): value range clamp; `alpha` (float): opacity
574
+ - Note: `extent` is accepted for compatibility but currently ignored.
575
+
576
+ ```python
577
+ im = ax.imshow([[1, 2], [3, 4]], cmap='plasma', origin='lower')
578
+ ```
579
+
580
+ ### colorbar
581
+
582
+ Add a colorbar for a mappable (e.g. the return value of `imshow` / `scatter`).
583
+
584
+ ```python
585
+ plt.colorbar(mappable=None, ax=None, **kwargs)
586
+ fig.colorbar(mappable=None, ax=None, **kwargs)
587
+ ```
588
+
589
+ **Effective keyword arguments:** `location`, `orientation`, `shrink`, `aspect`,
590
+ `pad`, `fraction`, `label`, `extend`, `ticks`, `format`. Other matplotlib kwargs
591
+ are accepted but currently have no effect.
592
+
593
+ ```python
594
+ im = plt.imshow([[1, 2], [3, 4]], cmap='viridis')
595
+ plt.colorbar(im, label='value', shrink=0.8)
596
+ ```
597
+
598
+ ### Color Normalization (LogNorm)
599
+
600
+ ```python
601
+ from rsplotlib.colors import LogNorm
602
+ plt.imshow(data, cmap='viridis', norm=LogNorm())
603
+ plt.colorbar()
604
+ ```
605
+
606
+ ### Math Text (`$...$`)
607
+
608
+ Any text-bearing API accepts LaTeX-style math between dollar signs, including
609
+ titles, axis labels, `text`, `annotate`, legend labels, and bar labels.
610
+
611
+ ```python
612
+ plt.title(r'$\alpha^2 + \frac{1}{2}\sqrt{x}$')
613
+ ```
614
+
615
+ Supported: superscripts/subscripts, `\frac`, `\sqrt[n]{}`, Greek letters,
616
+ accents, and font-style commands.
617
+
539
618
  ---
540
619
 
541
620
  ## Performance Advantages
@@ -572,9 +651,13 @@ rsplotlib achieves performance optimization through a layered-down architecture
572
651
  | --------------------------- | ---------------------------------------------- | ------------------------------------- |
573
652
  | `scatter(c=colors)` | Python iterates over every point | Rust `ScatterMulti` unified rendering |
574
653
  | `scatter(s=sizes)` | Python iterates over every point | Rust unified size array processing |
575
- | `hlines([y1, y2, y3, ...])` | Python `for` loop calling `axhline` repeatedly | Single Rust call, batch processing |
576
- | `vlines([x1, x2, x3, ...])` | Python `for` loop calling `axvline` repeatedly | Single Rust call, batch processing |
654
+ | `hlines([y1, y2, y3, ...])` | Python `for` loop calling `axhline` repeatedly | Single Rust call, batch processing |
655
+ | `vlines([x1, x2, x3, ...])` | Python `for` loop calling `axvline` repeatedly | Single Rust call, batch processing |
577
656
  | `savefig(dpi=300)` | No DPI support / Python scaling | Rust writes PNG DPI metadata directly |
657
+ | `hist()` / `boxplot()` (large data) | Python materializes every value | Zero-copy buffer push-down to Rust |
658
+ | Line plot with millions of points | Renders every segment | Automatic min/max (M4) decimation |
659
+ | `imshow` on large images | Single-threaded pixel loop | Multi-threaded row rendering |
660
+ | Repeated text rendering | Re-rasterize each glyph | Glyph cache keyed by (font, char, size) |
578
661
 
579
662
  ### Why a Rust + Python Hybrid Architecture?
580
663
 
@@ -703,6 +786,9 @@ PRs are welcome! Please include:
703
786
  - 3D plotting is not supported in the current version
704
787
  - Animated/interactive charts are not supported
705
788
  - `contour` / `violinplot` / `hexbin` are placeholder implementations
789
+ - `imshow(extent=...)` is accepted for signature compatibility but currently ignored
790
+ - `colorbar()` honors only a subset of matplotlib kwargs (see [colorbar](#colorbar))
791
+ - `data=` is currently supported by `scatter` only (not `plot`)
706
792
 
707
793
  ---
708
794
 
@@ -760,7 +846,8 @@ MIT License - See the [LICENSE](LICENSE) file for details.
760
846
  ## Related Links
761
847
 
762
848
  - **GitHub**: https://github.com/YJ-Niu/rsplotlib
849
+ - **Release Notes**: [RELEASE_NOTES.md](RELEASE_NOTES.md)
763
850
 
764
851
  ---
765
852
 
766
- _Last updated: 2026-07-03 / Version v0.1.9_
853
+ _Last updated: 2026-07-12 / Version v0.2.9_
@@ -46,6 +46,21 @@
46
46
  - **统计图表**:直方图、箱线图、饼图、误差棒图、茎叶图、阶梯图
47
47
  - **高级图表**:堆叠面积图、热力图/图像显示、填充区域图
48
48
 
49
+ ### 颜色映射与颜色条
50
+
51
+ - **50+ 内置颜色映射**:`viridis`、`plasma`、`inferno`、`magma`、`cividis`、`jet`、`coolwarm`、`RdBu`、`Blues`、`Greens`、`Reds`、`hot`、`cool`、`gray`、`terrain`、`twilight` 等,任意名称加 `_r` 后缀即可反转(如 `viridis_r`)
52
+ - **颜色条 Colorbar**:`plt.colorbar()` / `fig.colorbar()`,Rust 渲染,支持 `location`、`orientation`、`shrink`、`aspect`、`pad`、`fraction`、`label`、`extend`、`ticks`、`format`
53
+ - **颜色归一化**:`LogNorm` / `Normalize`(来自 `rsplotlib.colors`),通过 `norm=` 参数使用
54
+
55
+ ### 图像输入 / 输出
56
+
57
+ - **`imshow`**:支持二维数据(经颜色映射,可用对数归一化)与 RGB/RGBA 图像,支持 `alpha`、`origin`、`interpolation` 控制
58
+ - **`imread` / `imsave`**:读写 PNG/JPEG 图像
59
+
60
+ ### 数学公式渲染
61
+
62
+ - **LaTeX 风格 `$...$`**:上下标、`\frac`、`\sqrt[n]{}`、希腊字母、重音与字体样式命令,在标题、轴标签、`text`、`annotate`、图例、柱状图标签中生效
63
+
49
64
  ### 辅助元素
50
65
 
51
66
  - **参考线**:水平参考线 (`axhline`)、垂直参考线 (`axvline`)
@@ -332,24 +347,27 @@ plt.savefig('module_level.png')
332
347
 
333
348
  ### 绘图函数
334
349
 
335
- | 函数 | 说明 | 模块级接口 | Axes 接口 |
336
- | ---------------- | --------------------------- | ---------- | --------- |
337
- | `plot()` | 折线图 | ✅ | ✅ |
338
- | `scatter()` | 散点图(支持颜色/大小数组) | ✅ | ✅ |
339
- | `bar()` | 柱状图 | ✅ | ✅ |
340
- | `barh()` | 水平柱状图 | ✅ | ✅ |
341
- | `hist()` | 直方图 | ✅ | ✅ |
342
- | `pie()` | 饼图 | ✅ | ✅ |
343
- | `boxplot()` | 箱线图 | ✅ | ✅ |
344
- | `fill_between()` | 曲线间填充 | ✅ | ✅ |
345
- | `errorbar()` | 误差棒图 | ✅ | ✅ |
346
- | `stem()` | 茎叶图 | ✅ | ✅ |
347
- | `step()` | 阶梯图 | ✅ | ✅ |
348
- | `imshow()` | 图像/热力图 | ✅ | ✅ |
349
- | `stackplot()` | 堆叠面积图 | ✅ | ✅ |
350
- | `semilogx()` | x 轴对数坐标折线图 | ✅ | ✅ |
351
- | `semilogy()` | y 轴对数坐标折线图 | ✅ | ✅ |
352
- | `loglog()` | 双对数坐标折线图 | ✅ | ✅ |
350
+ | 函数 | 说明 | 模块级接口 | Axes 接口 |
351
+ | ---------------- | --------------------------- | ------------- | --------- |
352
+ | `plot()` | 折线图 | ✅ | ✅ |
353
+ | `scatter()` | 散点图(支持颜色/大小数组) | ✅ | ✅ |
354
+ | `bar()` | 柱状图 | ✅ | ✅ |
355
+ | `barh()` | 水平柱状图 | ✅ | ✅ |
356
+ | `hist()` | 直方图 | ✅ | ✅ |
357
+ | `pie()` | 饼图 | ✅ | ✅ |
358
+ | `boxplot()` | 箱线图 | ✅ | ✅ |
359
+ | `fill_between()` | 曲线间填充 | ✅ | ✅ |
360
+ | `errorbar()` | 误差棒图 | ✅ | ✅ |
361
+ | `stem()` | 茎叶图 | ✅ | ✅ |
362
+ | `step()` | 阶梯图 | ✅ | ✅ |
363
+ | `imshow()` | 图像/热力图 | ✅ | ✅ |
364
+ | `stackplot()` | 堆叠面积图 | ✅ | ✅ |
365
+ | `semilogx()` | x 轴对数坐标折线图 | ✅ | ✅ |
366
+ | `semilogy()` | y 轴对数坐标折线图 | ✅ | ✅ |
367
+ | `loglog()` | 双对数坐标折线图 | ✅ | ✅ |
368
+ | `colorbar()` | 为 mappable 添加颜色条 | ✅(plt/fig) | ❌ |
369
+ | `imread()` | 读取 PNG/JPEG 图像为数组 | ✅ | ❌ |
370
+ | `imsave()` | 将数组写出为 PNG/JPEG | ✅ | ❌ |
353
371
 
354
372
  ### 辅助元素
355
373
 
@@ -531,6 +549,66 @@ ax.vlines(x, color=None, linestyle=None, linewidth=None)
531
549
 
532
550
  - `y` / `x` (list/array): 位置列表
533
551
 
552
+ ### Axes.imshow / plt.imshow
553
+
554
+ 将二维数据显示为热力图,或渲染 RGB/RGBA 图像。
555
+
556
+ ```python
557
+ ax.imshow(x, cmap=None, norm=None, aspect=None, interpolation=None,
558
+ alpha=None, vmin=None, vmax=None, origin=None, extent=None)
559
+ ```
560
+
561
+ **参数:**
562
+
563
+ - `x` (二维数组或 HxWx3/4 图像): 标量场或 RGB(A) 图像
564
+ - `cmap` (str): 二维数据的颜色映射名(默认 `'viridis'`),加 `_r` 反转
565
+ - `norm` (`Normalize` / `LogNorm` / `'linear'` / `'log'`): 数值到颜色的映射
566
+ - `interpolation` (str): `'none'` / `'nearest'` 为块状缩放,其余为平滑模式
567
+ - `origin` (str): `'upper'`(默认)或 `'lower'`
568
+ - `vmin` / `vmax` (float): 数值范围裁剪;`alpha` (float): 不透明度
569
+ - 注意:`extent` 为兼容签名而接受,但当前被忽略
570
+
571
+ ```python
572
+ im = ax.imshow([[1, 2], [3, 4]], cmap='plasma', origin='lower')
573
+ ```
574
+
575
+ ### colorbar
576
+
577
+ 为 mappable(如 `imshow` / `scatter` 的返回值)添加颜色条。
578
+
579
+ ```python
580
+ plt.colorbar(mappable=None, ax=None, **kwargs)
581
+ fig.colorbar(mappable=None, ax=None, **kwargs)
582
+ ```
583
+
584
+ **生效的关键字参数:** `location`、`orientation`、`shrink`、`aspect`、`pad`、
585
+ `fraction`、`label`、`extend`、`ticks`、`format`。其余 matplotlib 关键字虽被接受,
586
+ 但当前不生效。
587
+
588
+ ```python
589
+ im = plt.imshow([[1, 2], [3, 4]], cmap='viridis')
590
+ plt.colorbar(im, label='数值', shrink=0.8)
591
+ ```
592
+
593
+ ### 颜色归一化(LogNorm)
594
+
595
+ ```python
596
+ from rsplotlib.colors import LogNorm
597
+ plt.imshow(data, cmap='viridis', norm=LogNorm())
598
+ plt.colorbar()
599
+ ```
600
+
601
+ ### 数学公式(`$...$`)
602
+
603
+ 所有承载文本的接口都支持美元符号之间的 LaTeX 风格公式,包括标题、轴标签、
604
+ `text`、`annotate`、图例标签与柱状图标签。
605
+
606
+ ```python
607
+ plt.title(r'$\alpha^2 + \frac{1}{2}\sqrt{x}$')
608
+ ```
609
+
610
+ 支持:上下标、`\frac`、`\sqrt[n]{}`、希腊字母、重音与字体样式命令。
611
+
534
612
  ---
535
613
 
536
614
  ## 性能优势
@@ -558,13 +636,17 @@ rsplotlib 在架构设计上通过"分层下沉"策略实现性能优化:
558
636
 
559
637
  ### 性能关键路径下沉到 Rust
560
638
 
561
- | 功能 | 传统实现 | rsplotlib 实现 |
562
- | --------------------------- | ----------------------------------- | ------------------------------- |
563
- | `scatter(c=colors)` | Python 层遍历每个点 | Rust 层 `ScatterMulti` 统一渲染 |
564
- | `scatter(s=sizes)` | Python 层遍历每个点 | Rust 层统一大小数组处理 |
565
- | `hlines([y1, y2, y3, ...])` | Python `for` 循环多次调用 `axhline` | Rust 层单次调用批量处理 |
566
- | `vlines([x1, x2, x3, ...])` | Python `for` 循环多次调用 `axvline` | Rust 层单次调用批量处理 |
567
- | `savefig(dpi=300)` | 无 DPI 支持 / Python 层缩放 | Rust 层直接写入 PNG DPI 元数据 |
639
+ | 功能 | 传统实现 | rsplotlib 实现 |
640
+ | -------------------------------- | ----------------------------------- | ------------------------------- |
641
+ | `scatter(c=colors)` | Python 层遍历每个点 | Rust 层 `ScatterMulti` 统一渲染 |
642
+ | `scatter(s=sizes)` | Python 层遍历每个点 | Rust 层统一大小数组处理 |
643
+ | `hlines([y1, y2, y3, ...])` | Python `for` 循环多次调用 `axhline` | Rust 层单次调用批量处理 |
644
+ | `vlines([x1, x2, x3, ...])` | Python `for` 循环多次调用 `axvline` | Rust 层单次调用批量处理 |
645
+ | `savefig(dpi=300)` | 无 DPI 支持 / Python 层缩放 | Rust 层直接写入 PNG DPI 元数据 |
646
+ | `hist()` / `boxplot()`(大数据) | Python 层物化每个数值 | 零拷贝缓冲区下沉到 Rust |
647
+ | 百万级点折线 | 渲染每一段线段 | 自动 min/max(M4)抽稀 |
648
+ | 大图 `imshow` | 单线程逐像素 | 多线程按行渲染 |
649
+ | 重复文本渲染 | 每个字形重复栅格化 | 按 (字体, 字符, 字号) 缓存字形 |
568
650
 
569
651
  ### 为什么选择 Rust + Python 混合架构
570
652
 
@@ -693,6 +775,9 @@ def axhspan(ymin, ymax, **kwargs):
693
775
  - 当前版本不支持 3D 绘图
694
776
  - 不支持动画/交互式图表
695
777
  - `contour` / `violinplot` / `hexbin` 为占位实现
778
+ - `imshow(extent=...)` 为兼容签名而接受,但当前被忽略
779
+ - `colorbar()` 仅部分 matplotlib 关键字生效(见 [colorbar](#colorbar))
780
+ - `data=` 当前仅 `scatter` 支持(`plot` 不支持)
696
781
 
697
782
  ---
698
783
 
@@ -750,7 +835,8 @@ MIT License — 详见 [LICENSE](LICENSE) 文件。
750
835
  ## 相关链接
751
836
 
752
837
  - **GitHub**: https://github.com/YJ-Niu/rsplotlib
838
+ - **发行说明**: [RELEASE_NOTES_zh.md](RELEASE_NOTES_zh.md)
753
839
 
754
840
  ---
755
841
 
756
- _最后更新:2026-07-03 · 版本 v0.1.9_
842
+ _最后更新:2026-07-12 · 版本 v0.2.9_