plot-io 0.3.0__tar.gz → 0.7.0__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 (303) hide show
  1. plot_io-0.7.0/API.md +3165 -0
  2. {plot_io-0.3.0 → plot_io-0.7.0}/EXAMPLES.md +212 -38
  3. {plot_io-0.3.0 → plot_io-0.7.0}/PKG-INFO +49 -11
  4. {plot_io-0.3.0 → plot_io-0.7.0}/README.md +44 -8
  5. {plot_io-0.3.0 → plot_io-0.7.0}/examples/annotated.py +1 -1
  6. {plot_io-0.3.0 → plot_io-0.7.0}/examples/bars.py +6 -6
  7. {plot_io-0.3.0 → plot_io-0.7.0}/examples/box_plots.py +1 -1
  8. plot_io-0.7.0/examples/colorbars.py +42 -0
  9. {plot_io-0.3.0 → plot_io-0.7.0}/examples/density.py +4 -4
  10. {plot_io-0.3.0 → plot_io-0.7.0}/examples/distributions.py +3 -3
  11. {plot_io-0.3.0 → plot_io-0.7.0}/examples/facets.py +3 -3
  12. plot_io-0.7.0/examples/genome_tracks.py +70 -0
  13. {plot_io-0.3.0 → plot_io-0.7.0}/examples/grids2d.py +4 -4
  14. {plot_io-0.3.0 → plot_io-0.7.0}/examples/groups.py +2 -2
  15. plot_io-0.7.0/examples/heatmap.py +16 -0
  16. {plot_io-0.3.0 → plot_io-0.7.0}/examples/layouts.py +1 -1
  17. {plot_io-0.3.0 → plot_io-0.7.0}/examples/scales.py +1 -1
  18. {plot_io-0.3.0 → plot_io-0.7.0}/examples/scatter_groups.py +1 -2
  19. {plot_io-0.3.0 → plot_io-0.7.0}/examples/shared_colorbar.py +4 -4
  20. plot_io-0.7.0/examples/shared_legend.py +50 -0
  21. plot_io-0.7.0/examples/shared_sizes.py +29 -0
  22. {plot_io-0.3.0 → plot_io-0.7.0}/examples/time_twin.py +1 -1
  23. plot_io-0.7.0/examples/titles.py +45 -0
  24. {plot_io-0.3.0 → plot_io-0.7.0}/examples/units.py +1 -1
  25. {plot_io-0.3.0 → plot_io-0.7.0}/examples/variable_fonts.py +2 -2
  26. plot_io-0.7.0/plot_io/__init__.py +57 -0
  27. plot_io-0.7.0/plot_io/_backend.py +43 -0
  28. plot_io-0.7.0/plot_io/_native/README.md +96 -0
  29. plot_io-0.7.0/plot_io/_native/__init__.py +188 -0
  30. plot_io-0.7.0/plot_io/_native/_api.py +365 -0
  31. plot_io-0.7.0/plot_io/_native/bin/linux-aarch64.so +0 -0
  32. plot_io-0.7.0/plot_io/_native/bin/linux-x86_64.so +0 -0
  33. plot_io-0.7.0/plot_io/_native/bin/macos-arm64.dylib +0 -0
  34. plot_io-0.7.0/plot_io/_native/bin/windows-arm64.dll +0 -0
  35. plot_io-0.7.0/plot_io/_native/bin/windows-x86_64.dll +0 -0
  36. plot_io-0.7.0/plot_io/_native/kernels.py +326 -0
  37. plot_io-0.7.0/plot_io/_native/manifest.json +49 -0
  38. plot_io-0.7.0/plot_io/_native/src/alloc.c +163 -0
  39. plot_io-0.7.0/plot_io/_native/src/colormap.c +205 -0
  40. plot_io-0.7.0/plot_io/_native/src/data.c +47 -0
  41. plot_io-0.7.0/plot_io/_native/src/math.c +359 -0
  42. plot_io-0.7.0/plot_io/_native/src/plio.h +126 -0
  43. plot_io-0.7.0/plot_io/_native/src/plio_api.h +246 -0
  44. plot_io-0.7.0/plot_io/_native/src/plot.c +1679 -0
  45. plot_io-0.7.0/plot_io/_native/src/rt.c +104 -0
  46. plot_io-0.7.0/plot_io/_native/src/signatures.c +267 -0
  47. plot_io-0.7.0/plot_io/_native/src/stats.c +671 -0
  48. plot_io-0.7.0/plot_io/_threads.py +43 -0
  49. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/axis.py +275 -100
  50. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/color/__init__.py +1 -1
  51. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/color/data.py +13 -9
  52. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/color/maps.py +118 -35
  53. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/color/palettes.py +10 -9
  54. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/color/values.py +45 -12
  55. plot_io-0.7.0/plot_io/colorbar.py +1040 -0
  56. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/decorations.py +31 -28
  57. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/defaults.py +231 -220
  58. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/density.py +8 -8
  59. plot_io-0.7.0/plot_io/facets.py +205 -0
  60. plot_io-0.7.0/plot_io/figure.py +632 -0
  61. plot_io-0.7.0/plot_io/genome/__init__.py +11 -0
  62. plot_io-0.7.0/plot_io/genome/layout.py +136 -0
  63. plot_io-0.7.0/plot_io/genome/pack.py +23 -0
  64. plot_io-0.7.0/plot_io/genome/regions.py +127 -0
  65. plot_io-0.7.0/plot_io/genome/scale.py +137 -0
  66. plot_io-0.7.0/plot_io/genome/sources.py +296 -0
  67. plot_io-0.7.0/plot_io/genome/tracks.py +1254 -0
  68. plot_io-0.7.0/plot_io/geometry.py +293 -0
  69. plot_io-0.7.0/plot_io/groups.py +294 -0
  70. plot_io-0.7.0/plot_io/kernels.py +551 -0
  71. plot_io-0.7.0/plot_io/labels.py +70 -0
  72. plot_io-0.7.0/plot_io/layers/__init__.py +66 -0
  73. plot_io-0.7.0/plot_io/layers/base.py +387 -0
  74. plot_io-0.7.0/plot_io/layers/context.py +72 -0
  75. plot_io-0.7.0/plot_io/layers/core.py +272 -0
  76. plot_io-0.7.0/plot_io/layers/geoms.py +1206 -0
  77. plot_io-0.3.0/plot_io/series/points.py → plot_io-0.7.0/plot_io/layers/paint.py +167 -133
  78. plot_io-0.7.0/plot_io/layers/pipeline.py +91 -0
  79. plot_io-0.7.0/plot_io/layers/positions.py +238 -0
  80. plot_io-0.7.0/plot_io/layers/stats.py +442 -0
  81. plot_io-0.7.0/plot_io/layout.py +1916 -0
  82. plot_io-0.7.0/plot_io/legend.py +712 -0
  83. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/limits.py +2 -0
  84. plot_io-0.7.0/plot_io/mapped.py +458 -0
  85. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/markers.py +7 -7
  86. plot_io-0.7.0/plot_io/markup.py +128 -0
  87. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/numbers.py +4 -23
  88. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/occupancy.py +3 -2
  89. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/plot.py +130 -171
  90. plot_io-0.7.0/plot_io/presets/__init__.py +42 -0
  91. plot_io-0.7.0/plot_io/presets/_util.py +260 -0
  92. {plot_io-0.3.0/plot_io/series → plot_io-0.7.0/plot_io/presets}/area.py +78 -83
  93. plot_io-0.7.0/plot_io/presets/bar.py +257 -0
  94. plot_io-0.7.0/plot_io/presets/box.py +382 -0
  95. plot_io-0.7.0/plot_io/presets/catpoints.py +174 -0
  96. plot_io-0.7.0/plot_io/presets/contour.py +303 -0
  97. plot_io-0.7.0/plot_io/presets/curves.py +30 -0
  98. plot_io-0.7.0/plot_io/presets/ecdf.py +97 -0
  99. plot_io-0.7.0/plot_io/presets/errorbar.py +119 -0
  100. {plot_io-0.3.0/plot_io/series → plot_io-0.7.0/plot_io/presets}/errors.py +65 -38
  101. plot_io-0.7.0/plot_io/presets/fill.py +94 -0
  102. plot_io-0.7.0/plot_io/presets/heatmap.py +288 -0
  103. plot_io-0.7.0/plot_io/presets/hexbin.py +183 -0
  104. plot_io-0.7.0/plot_io/presets/hist.py +360 -0
  105. plot_io-0.7.0/plot_io/presets/hist2d.py +78 -0
  106. plot_io-0.7.0/plot_io/presets/kde.py +166 -0
  107. plot_io-0.7.0/plot_io/presets/kde2d.py +126 -0
  108. plot_io-0.7.0/plot_io/presets/line.py +154 -0
  109. plot_io-0.7.0/plot_io/presets/pie.py +457 -0
  110. plot_io-0.7.0/plot_io/presets/regression.py +120 -0
  111. plot_io-0.7.0/plot_io/presets/scatter.py +125 -0
  112. plot_io-0.7.0/plot_io/presets/stem.py +96 -0
  113. plot_io-0.7.0/plot_io/presets/violin.py +301 -0
  114. plot_io-0.7.0/plot_io/py.typed +0 -0
  115. plot_io-0.7.0/plot_io/render.py +381 -0
  116. plot_io-0.7.0/plot_io/rows.py +416 -0
  117. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/scales.py +7 -6
  118. plot_io-0.7.0/plot_io/seams.py +119 -0
  119. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/settings.py +269 -121
  120. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/shapes.py +16 -8
  121. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/sharing.py +67 -21
  122. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/sizemaps.py +15 -18
  123. plot_io-0.7.0/plot_io/spec.py +204 -0
  124. plot_io-0.7.0/plot_io/states.py +175 -0
  125. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/stats.py +19 -21
  126. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/styles/__init__.py +58 -29
  127. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/styles/library.py +92 -48
  128. plot_io-0.7.0/plot_io/text.py +265 -0
  129. plot_io-0.7.0/plot_io/titles.py +140 -0
  130. plot_io-0.7.0/plot_io/transform.py +108 -0
  131. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/units.py +95 -38
  132. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/values.py +2 -3
  133. plot_io-0.7.0/pyproject.toml +43 -0
  134. plot_io-0.7.0/tests/fonts/PioTest-Bold.ttf +0 -0
  135. plot_io-0.7.0/tests/fonts/PioTest-Regular.ttf +0 -0
  136. plot_io-0.7.0/tests/golden.json +186 -0
  137. plot_io-0.7.0/tests/helpers.py +100 -0
  138. plot_io-0.7.0/tests/stats_reference.json +839 -0
  139. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_bars.py +117 -12
  140. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_box.py +11 -7
  141. plot_io-0.7.0/tests/test_colorbars.py +519 -0
  142. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_decorations.py +49 -6
  143. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_defaults.py +46 -22
  144. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_density.py +84 -28
  145. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_distributions.py +13 -9
  146. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_entry.py +20 -4
  147. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_figure_title.py +14 -3
  148. plot_io-0.7.0/tests/test_fonts.py +134 -0
  149. plot_io-0.7.0/tests/test_genome.py +853 -0
  150. plot_io-0.7.0/tests/test_geometry.py +368 -0
  151. plot_io-0.7.0/tests/test_golden.py +325 -0
  152. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_grids.py +7 -6
  153. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_heatmap.py +17 -10
  154. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_jxl_output.py +6 -5
  155. plot_io-0.7.0/tests/test_layers.py +149 -0
  156. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_layout.py +31 -24
  157. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_limits.py +3 -1
  158. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_maps.py +79 -29
  159. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_markers.py +6 -4
  160. plot_io-0.7.0/tests/test_markup.py +243 -0
  161. plot_io-0.7.0/tests/test_native.py +94 -0
  162. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_numbers.py +1 -1
  163. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_occupancy.py +12 -12
  164. plot_io-0.7.0/tests/test_output.py +211 -0
  165. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_palettes.py +4 -4
  166. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_pie.py +2 -2
  167. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_reflines.py +3 -3
  168. plot_io-0.7.0/tests/test_rows.py +176 -0
  169. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_series.py +15 -18
  170. plot_io-0.7.0/tests/test_settings.py +237 -0
  171. plot_io-0.7.0/tests/test_shared_legends.py +381 -0
  172. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_sharing.py +5 -2
  173. plot_io-0.7.0/tests/test_simplify.py +101 -0
  174. plot_io-0.7.0/tests/test_stats.py +98 -0
  175. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_style_settings.py +34 -17
  176. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_style_types.py +1 -0
  177. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_styles.py +13 -12
  178. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_tables.py +108 -11
  179. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_ticks.py +1 -0
  180. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_time_twin.py +3 -3
  181. plot_io-0.7.0/tests/test_titles.py +625 -0
  182. plot_io-0.7.0/tests/test_transform.py +101 -0
  183. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_units.py +26 -12
  184. plot_io-0.7.0/tests/test_values.py +351 -0
  185. plot_io-0.7.0/tests/test_vocabulary.py +130 -0
  186. plot_io-0.7.0/tools/build_native.py +640 -0
  187. plot_io-0.7.0/tools/settings_doc.py +193 -0
  188. plot_io-0.3.0/.gitignore +0 -19
  189. plot_io-0.3.0/API.md +0 -2051
  190. plot_io-0.3.0/examples/annotated.png +0 -0
  191. plot_io-0.3.0/examples/bars.png +0 -0
  192. plot_io-0.3.0/examples/box_plots.png +0 -0
  193. plot_io-0.3.0/examples/density.png +0 -0
  194. plot_io-0.3.0/examples/distributions.png +0 -0
  195. plot_io-0.3.0/examples/error_bars.png +0 -0
  196. plot_io-0.3.0/examples/facets.png +0 -0
  197. plot_io-0.3.0/examples/grids2d.png +0 -0
  198. plot_io-0.3.0/examples/groups.png +0 -0
  199. plot_io-0.3.0/examples/heatmap.png +0 -0
  200. plot_io-0.3.0/examples/heatmap.py +0 -16
  201. plot_io-0.3.0/examples/large_data.png +0 -0
  202. plot_io-0.3.0/examples/layout_axes.png +0 -0
  203. plot_io-0.3.0/examples/layout_borders.png +0 -0
  204. plot_io-0.3.0/examples/line_band.png +0 -0
  205. plot_io-0.3.0/examples/scales.png +0 -0
  206. plot_io-0.3.0/examples/scatter_groups.png +0 -0
  207. plot_io-0.3.0/examples/shared_colorbar.png +0 -0
  208. plot_io-0.3.0/examples/styles/altair-2.png +0 -0
  209. plot_io-0.3.0/examples/styles/altair.png +0 -0
  210. plot_io-0.3.0/examples/styles/bokeh-2.png +0 -0
  211. plot_io-0.3.0/examples/styles/bokeh.png +0 -0
  212. plot_io-0.3.0/examples/styles/chartjs-2.png +0 -0
  213. plot_io-0.3.0/examples/styles/chartjs.png +0 -0
  214. plot_io-0.3.0/examples/styles/default-2.png +0 -0
  215. plot_io-0.3.0/examples/styles/default.png +0 -0
  216. plot_io-0.3.0/examples/styles/economist-2.png +0 -0
  217. plot_io-0.3.0/examples/styles/economist.png +0 -0
  218. plot_io-0.3.0/examples/styles/excel-2.png +0 -0
  219. plot_io-0.3.0/examples/styles/excel.png +0 -0
  220. plot_io-0.3.0/examples/styles/fivethirtyeight-2.png +0 -0
  221. plot_io-0.3.0/examples/styles/fivethirtyeight.png +0 -0
  222. plot_io-0.3.0/examples/styles/ggplot2-2.png +0 -0
  223. plot_io-0.3.0/examples/styles/ggplot2-bw-2.png +0 -0
  224. plot_io-0.3.0/examples/styles/ggplot2-bw.png +0 -0
  225. plot_io-0.3.0/examples/styles/ggplot2.png +0 -0
  226. plot_io-0.3.0/examples/styles/matlab-2.png +0 -0
  227. plot_io-0.3.0/examples/styles/matlab.png +0 -0
  228. plot_io-0.3.0/examples/styles/matplotlib-2.png +0 -0
  229. plot_io-0.3.0/examples/styles/matplotlib-classic-2.png +0 -0
  230. plot_io-0.3.0/examples/styles/matplotlib-classic.png +0 -0
  231. plot_io-0.3.0/examples/styles/matplotlib.png +0 -0
  232. plot_io-0.3.0/examples/styles/observable-2.png +0 -0
  233. plot_io-0.3.0/examples/styles/observable.png +0 -0
  234. plot_io-0.3.0/examples/styles/plotly-2.png +0 -0
  235. plot_io-0.3.0/examples/styles/plotly-white-2.png +0 -0
  236. plot_io-0.3.0/examples/styles/plotly-white.png +0 -0
  237. plot_io-0.3.0/examples/styles/plotly.png +0 -0
  238. plot_io-0.3.0/examples/styles/seaborn-2.png +0 -0
  239. plot_io-0.3.0/examples/styles/seaborn-whitegrid-2.png +0 -0
  240. plot_io-0.3.0/examples/styles/seaborn-whitegrid.png +0 -0
  241. plot_io-0.3.0/examples/styles/seaborn.png +0 -0
  242. plot_io-0.3.0/examples/styles/tufte-2.png +0 -0
  243. plot_io-0.3.0/examples/styles/tufte.png +0 -0
  244. plot_io-0.3.0/examples/time_twin.png +0 -0
  245. plot_io-0.3.0/examples/units.png +0 -0
  246. plot_io-0.3.0/examples/variable_fonts.png +0 -0
  247. plot_io-0.3.0/plot_io/__init__.py +0 -67
  248. plot_io-0.3.0/plot_io/_backend.py +0 -121
  249. plot_io-0.3.0/plot_io/colorbar.py +0 -364
  250. plot_io-0.3.0/plot_io/enums.py +0 -64
  251. plot_io-0.3.0/plot_io/facets.py +0 -184
  252. plot_io-0.3.0/plot_io/figure.py +0 -376
  253. plot_io-0.3.0/plot_io/labels.py +0 -45
  254. plot_io-0.3.0/plot_io/legend.py +0 -499
  255. plot_io-0.3.0/plot_io/render.py +0 -1209
  256. plot_io-0.3.0/plot_io/series/__init__.py +0 -526
  257. plot_io-0.3.0/plot_io/series/bar.py +0 -294
  258. plot_io-0.3.0/plot_io/series/box.py +0 -402
  259. plot_io-0.3.0/plot_io/series/catdata.py +0 -23
  260. plot_io-0.3.0/plot_io/series/catpoints.py +0 -185
  261. plot_io-0.3.0/plot_io/series/contour.py +0 -297
  262. plot_io-0.3.0/plot_io/series/curves.py +0 -128
  263. plot_io-0.3.0/plot_io/series/ecdf.py +0 -147
  264. plot_io-0.3.0/plot_io/series/errorbar.py +0 -113
  265. plot_io-0.3.0/plot_io/series/fill.py +0 -170
  266. plot_io-0.3.0/plot_io/series/heatmap.py +0 -297
  267. plot_io-0.3.0/plot_io/series/hexbin.py +0 -220
  268. plot_io-0.3.0/plot_io/series/hist.py +0 -390
  269. plot_io-0.3.0/plot_io/series/hist2d.py +0 -163
  270. plot_io-0.3.0/plot_io/series/kde.py +0 -238
  271. plot_io-0.3.0/plot_io/series/kde2d.py +0 -154
  272. plot_io-0.3.0/plot_io/series/line.py +0 -172
  273. plot_io-0.3.0/plot_io/series/pie.py +0 -324
  274. plot_io-0.3.0/plot_io/series/regression.py +0 -254
  275. plot_io-0.3.0/plot_io/series/scatter.py +0 -104
  276. plot_io-0.3.0/plot_io/series/stem.py +0 -114
  277. plot_io-0.3.0/plot_io/series/violin.py +0 -324
  278. plot_io-0.3.0/plot_io/slots.py +0 -62
  279. plot_io-0.3.0/plot_io/stacking.py +0 -63
  280. plot_io-0.3.0/plot_io/text.py +0 -132
  281. plot_io-0.3.0/pyproject.toml +0 -35
  282. plot_io-0.3.0/tests/golden.json +0 -21
  283. plot_io-0.3.0/tests/helpers.py +0 -17
  284. plot_io-0.3.0/tests/test_fonts.py +0 -65
  285. plot_io-0.3.0/tests/test_golden.py +0 -101
  286. plot_io-0.3.0/tests/test_output.py +0 -109
  287. plot_io-0.3.0/tests/test_settings.py +0 -95
  288. plot_io-0.3.0/tests/test_simplify.py +0 -67
  289. plot_io-0.3.0/tests/test_values.py +0 -175
  290. plot_io-0.3.0/tools/bench.py +0 -225
  291. plot_io-0.3.0/tools/dist.py +0 -80
  292. plot_io-0.3.0/tools/settings_doc.py +0 -125
  293. {plot_io-0.3.0 → plot_io-0.7.0}/LICENSE +0 -0
  294. {plot_io-0.3.0 → plot_io-0.7.0}/examples/error_bars.py +0 -0
  295. {plot_io-0.3.0 → plot_io-0.7.0}/examples/large_data.py +0 -0
  296. {plot_io-0.3.0 → plot_io-0.7.0}/examples/line_band.py +0 -0
  297. {plot_io-0.3.0 → plot_io-0.7.0}/examples/styles.py +0 -0
  298. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/lines.py +0 -0
  299. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/tables.py +0 -0
  300. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/ticks.py +0 -0
  301. {plot_io-0.3.0 → plot_io-0.7.0}/plot_io/times.py +0 -0
  302. {plot_io-0.3.0 → plot_io-0.7.0}/tests/fonts/VarTest.ttf +0 -0
  303. {plot_io-0.3.0 → plot_io-0.7.0}/tests/test_docs.py +0 -0
plot_io-0.7.0/API.md ADDED
@@ -0,0 +1,3165 @@
1
+ # plot_io API
2
+
3
+ Complete reference. Worked examples are in [EXAMPLES.md](EXAMPLES.md).
4
+
5
+ 1. [Conventions](#1-conventions)
6
+ 2. [Figures](#2-figures)
7
+ 3. [Plots](#3-plots)
8
+ 4. [Axes](#4-axes)
9
+ 5. [Series](#5-series)
10
+ 6. [Color and size axes](#6-color-and-size-axes)
11
+ 7. [Colors, maps and markers](#7-colors-maps-and-markers)
12
+ 8. [Output](#8-output)
13
+ 9. [Genome tracks](#9-genome-tracks)
14
+ 10. [Styles](#10-styles)
15
+ 11. [Errors](#11-errors)
16
+ 12. [Modules](#12-modules)
17
+
18
+ ## 1. Conventions
19
+
20
+ * **Model.** A `Figure` holds plots (and colorbars) in a grid, and titles; a `Plot` holds
21
+ series, two axes, titles, a legend and colorbars; a series holds data and style. Nothing is
22
+ computed until the figure is drawn (`save`, `to_bytes`, `draw`), so settings can change
23
+ in any order.
24
+ * **Settings.** Every object takes its settings as keywords when created and in
25
+ `set(**settings)`, which returns the object. `set(name=None)` goes back to the inherited
26
+ or default value. `get(name)` returns the value as given (`"4.5pt"`, `"var(color)"`),
27
+ `resolve(name)` the final one (px, degrees, colors), and `explain(name)` where it comes
28
+ from ([values](#values)). Unknown names and invalid values raise `ValueError` naming
29
+ the setting (with the nearest valid name).
30
+ * **Inheritance.** Settings marked *inherited* in the tables (font, line width, palette,
31
+ alpha, `rasterize`, `simplify`) are looked up series → plot → figure → style.
32
+ * **Setting groups.** Settings that travel together are declared once as a group and
33
+ embedded by each owner: `Font` (family, size, variable-font axes), `TextStyle` (size,
34
+ weight, style, color of one text element), `Stroke` (color, width, dash style, caps,
35
+ joins), `Marker`, `FillStyle` (`fill`: on or off, an opacity or a color) and
36
+ `NumberFormat`. The naming rule: an owner's primary element takes a group unprefixed, a
37
+ secondary one prefixed, and every member's prefixed name follows its pattern. A
38
+ scatter's markers are `size`, `edge_color`, …; a line's are `marker_size`,
39
+ `marker_edge_color`; a box's whiskers are `whisker_color`, `whisker_width`,
40
+ `whisker_style`; an axis' tick labels are `tick_label_font_size`, `tick_label_weight`,
41
+ `tick_label_color`. Each table ends with the groups the class embeds and their
42
+ prefixes; [groups](#setting-groups) lists the members.
43
+ * **Defaults.** Every default is in one dict, `pl.DEFAULTS` (`plot_io/defaults.py`; read
44
+ it, do not change it: styles set other values): bare names for inherited settings (font size,
45
+ sans-serif, black text, line width, `simplify="auto"`, the palette, …),
46
+ `"Class.name"` for the settings of each class and `"Group.member"` for every embedding
47
+ of a group member (`"Marker.size"`: every marker size). A class without an entry uses
48
+ its base class's, then the group's. Entries are plain data: a default that follows
49
+ another setting is written with units, `var()` or `calc()` (a legend's font is `"1em"`,
50
+ a minor tick `"60%"` of the tick length), and a class default of an inherited setting
51
+ scales the inherited value with `inherit` (a regression line is
52
+ `"calc(1.4 * inherit)"`, a fill's opacity `"calc(0.3 * inherit)"`). `"XAxis.name"` and
53
+ `"YAxis.name"` give one axis its own default.
54
+ * **`"auto"`.** A setting whose default is `"auto"` documents its rule. Rules that follow
55
+ from the model (a colorbar's orientation from its side, a legend's inner pad from
56
+ its frame, a genome track's gap) are resolved with the setting: `resolve()` returns the
57
+ result and `get()` `"auto"`. Rules that need the data or the layout (axis limits,
58
+ padding, tick count and rotation, number formats, legend placement) are resolved when
59
+ the figure is drawn.
60
+ * **Resolution.** One cascade finds every value, for `resolve`, `get` and `explain`:
61
+ 1. the value set on the object; for a plot's x or y axis, then the value set on the
62
+ figure's axis of that role (`fig.x_axis(…)`);
63
+ 2. a rule of the class (a track's axis lines from its content);
64
+ 3. the style's key for the object's class, then for its base classes (`"Series.alpha"`
65
+ reaches every series), stopping at a class that has a default of its own;
66
+ 4. for inherited settings, the parent's value (unless the class default refers to it
67
+ with `inherit`);
68
+ 5. the style's key for the setting's group (`"Marker.size"`);
69
+ 6. the class default, then the group default;
70
+ 7. for inherited settings, the style's bare name, then `DEFAULTS`'.
71
+
72
+ An owner's key always comes before its group's: `"Line.marker_size"` overrides
73
+ `"Marker.size"` for lines.
74
+ * **Styles.** `Figure(style=…)` presets settings: a style name or a dict of settings,
75
+ merged over the inherited defaults (the bare names of `DEFAULTS`). See [Styles](#styles).
76
+ * **Entry points.** `pl.Figure()`, `pl.Plot()` and the series classes (`pl.Scatter()`, …)
77
+ each create the levels above them: `pl.Scatter(x, y)` makes a plot (`.plot`) in a new
78
+ figure (`.plot.figure`). `fig.plot(…)` is `pl.Plot(figure=fig, …)` and `p.scatter(…)` is
79
+ `pl.Scatter(…, plot=p)`. Keywords that belong to a level above go to it when the call
80
+ creates that level: `pl.Scatter(x, y, width=300, title="T")` makes and sets the plot and
81
+ the figure. Adding to an existing plot or figure takes the new object's settings only:
82
+ `p.scatter(x, y, title="T")` raises `ValueError` naming `plot.set(title=…)`. A name
83
+ present on several levels goes to the lowest.
84
+ * **Units.** Lengths take units (`"1.5in"`, `"0.5em"`, `"60%"`); bare numbers are CSS px
85
+ (1 px = 1/96 in = 0.75 pt) everywhere. Slot widths (`Bar`, `Box`, `Violin`, `Strip`,
86
+ `Swarm` `width`) are `"80%"` of the slot or `"0.8d"` in data units. Positions along an
87
+ axis (a decoration's `min`/`max`) take bare numbers as data values. See
88
+ [values](#values).
89
+ Images are `dpi` pixels per inch: `dpi=96` gives one image pixel per px, the default 384
90
+ four. A dpi up to 16 is a multiple of 96: `dpi=2` is 192. PDF pages are sized in pt (× 0.75).
91
+ * **Data.** Sequences (`None` = missing), `array.array`, or any buffer (numpy arrays are
92
+ read without importing numpy). NaN or `None` values are missing: scatter skips them,
93
+ line and fill break there, box ignores them, heatmap cells take `nan_color`.
94
+ With `data=` (a table), strings in data arguments name its columns
95
+ ([tables](#tables-data)); dates make time axes ([dates](#dates-and-times)).
96
+ * **Text.** Titles, axis labels and legend entries are strings or rich content: a list of
97
+ strings and `pl.Span` (vec_io's), e.g. `["Area (m", pl.Span("2",
98
+ baseline_shift="super", font_scale=0.7), ")"]`. Strings take markup:
99
+ `"Growth of <i>E. coli</i> at <b>37 °C</b>"`, `"Area (m<sup>2</sup>)"`. Tags: `<i>`/`<em>`
100
+ italic, `<b>`/`<strong>` bold, `<u>` underline, `<s>`/`<del>` strikethrough, `<sup>` and
101
+ `<sub>` (0.7 of the size, raised 0.33 em or lowered 0.2 em), in either case, nested,
102
+ each closed by its own end tag; an unclosed or crossed tag is an error. Styles add to the text's own (`<b>`
103
+ in a bold title stays bold). Any other `<` is text (`x < 5`, `<0.05`); `&lt;`, `&gt;` and
104
+ `&amp;` write `<`, `>` and `&`. Strings inside rich content are read too; tick labels
105
+ take no markup. `markup=False` (inherited: on the figure, a plot or a text element) keeps
106
+ strings literal; `get()` returns the string as given.
107
+ * **Named colors.** `"blue"`, `"blue 0.45"`, `"blue 45%"`: 28 scales (`red`, `orange`,
108
+ `amber`, `yellow`, `lime`, `green`, `emerald`, `teal`, `cyan`, `sky`, `blue`, `indigo`,
109
+ `violet`, `purple`, `fuchsia`, `pink`, `rose`, `slate`, `gray`/`grey`, `zinc`, `neutral`,
110
+ `stone`, `taupe`, `mauve`, `mist`, `olive`, `black`, `white`), Tailwind CSS 4's OKLCh
111
+ shades 100–900 at levels 0.1–0.9, white at 0 and black at 1, interpolated in Oklab between
112
+ and gamut mapped into sRGB as CSS Color 4 specifies;
113
+ a bare name is level 0.5. They take precedence over CSS's names (`"red"` is `#fb2c36`,
114
+ not `#ff0000`); other CSS names (`"navy"`) keep their CSS values. `get()` returns the
115
+ name as given, `resolve()` the hex color.
116
+ * **Colors.** Named colors (above), any color vec_io accepts: CSS names, `"#rrggbb[aa]"`, CSS Color 4 functions
117
+ (`"rgb(…)"`, `"hsl(…)"`, `"hwb(…)"`, `"lab(…)"`, `"lch(…)"`, `"oklab(…)"`,
118
+ `"oklch(64.5% 0.246 16.439)"`, `"color(display-p3 1 0 0)"`, …; colors outside sRGB are
119
+ gamut mapped as browsers do), tuples of numbers in [0, 1] (`(1, 0.5, 0)`; on the 0–255
120
+ scale write `"rgb(255 128 0)"`), `CMYK` and `Spot`; and `"C0"`, `"C1"`, … for the
121
+ palette's colors.
122
+ * **Fonts.** `font_family` is a CSS family list; weights (`font_weight`, `label_weight`,
123
+ `tick_label_weight`) are `normal`, `bold` or 1–1000, styles `normal`, `italic`,
124
+ `oblique` or `"oblique 10deg"`. With a variable font (vec_io embeds the instance used),
125
+ the weight sets `wght`, the inherited `font_stretch` (`"condensed"`, `"87.5%"`) sets
126
+ `wdth`, the style `ital` or `slnt`, `font_optical_sizing="auto"` sets `opsz` from the
127
+ font size, and `font_variations` (`{"GRAD": 50}`) any axis:
128
+ `pl.Figure(font_family="Roboto Flex", font_stretch="85%", font_variations={"GRAD": 50})`.
129
+ * **Text and fonts.** Text is shaped by `vec_io.text` (pairs kerned) and its fonts are
130
+ embedded as subsets; plot text needs an installed outline font. Each character takes
131
+ the first family of `font_family` that is available (output options `font_dirs`, then
132
+ `VEC_IO_FONT_DIRS`, then installed fonts unless `system_fonts=False`; a family that is
133
+ not installed tries its metric aliases first: Helvetica and Arial → Liberation Sans,
134
+ Arimo, …), then a generic family's list (`sans-serif`: Arial, Helvetica, Liberation
135
+ Sans, DejaVu Sans, Noto Sans, …), then any font with the character. The default
136
+ `"Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo"` is Helvetica where
137
+ installed, else the first of the others installed (all have Helvetica's widths); with
138
+ none installed, vec_io downloads Nimbus Sans (URW's base 35 fonts). With no outline
139
+ font at all, output raises
140
+ `NoFontError` (a `ValueError`, from vec_io). A line of text is `line_height` tall (a
141
+ multiple of the font size; default 1), the glyphs centered in it, so the gaps around
142
+ text do not change with the font; `"normal"` takes the font's ascent and descent.
143
+ * **Names.** `pl.` holds the figure and plot classes, the plot types, the value types
144
+ (`ColorAxis`, `SizeAxis`, `ColorMap`, `SizeMap`, `Palette`, `Density`, `ErrorBars`,
145
+ `Span`), `facet`, the registries (`register_layer`, `register_marker`,
146
+ `register_color_map`, `register_palette`, `register_style`), `styles` (the styles
147
+ module), `set_style`, `use_style` and `DEFAULTS`; see [modules](#12-modules) for the
148
+ rest. Enum-like settings take strings.
149
+
150
+ ### Values
151
+
152
+ Every length, angle and number setting takes a value with a unit, a reference to another
153
+ setting, or an expression:
154
+
155
+ ```python
156
+ pl.Plot(width="3in", font_size="9pt", title="T")
157
+ p.x_axis(tick_length="0.5em", minor_tick_length="50%", tick_rotation="0.125turn")
158
+ p.bar(days, counts, width="20h") # a duration on a time axis
159
+ p.box(groups, positions=[1, 4, 9], width="0.8d") # data units (default: 80% of the slot)
160
+ p.errorbar(x, y, y_error=e, cap_length="0.2d") # data units across the bar
161
+ p.title(font_size="large", color="var(--accent)")
162
+ p.legend(pad="calc(1em - 2px)")
163
+ fig.set(vars={"accent": "#c00"}) # custom variables, read by var(--name)
164
+ ```
165
+
166
+ | Unit | Meaning |
167
+ |---|---|
168
+ | bare number | px (lengths), degrees (angles) |
169
+ | `px` `pt` `pc` `in` `cm` `mm` `Q` | absolute lengths |
170
+ | `em` | the object's `font_size`; in a `font_size` setting, the parent's |
171
+ | `rem` | the figure's `font_size` |
172
+ | `%` | of the reference the setting's type declares and its table entry names: another setting (`minor_tick_length`: of `tick_length`), or one of the [referents](#referents) |
173
+ | `d`, `data` | along a data axis: data units on linear axes, categories on category axes, seconds on time axes; an error on log, symlog and logit axes. On a time axis `d` is a day |
174
+ | `ms` `s` `min` `h` `d` `w` | durations, as data units of time axes (a `timedelta` too) |
175
+ | `fr` | a share of the room left by fixed tracks, in `Figure.widths`/`heights` |
176
+ | `deg` `grad` `rad` `turn` | angles |
177
+ | `xx-small` … `xx-large`, `smaller`, `larger` | font sizes: × 0.579 … 1.728 of `rem`; ÷/× 1.2 of the parent's |
178
+
179
+ * **`var(name[, fallback])`** reads another setting of the object, resolved through the
180
+ usual inheritance. **`inherit`** (or `var()` of the setting's own name) reads the
181
+ parent's value of the same setting (`alpha="calc(inherit / 2)"`). `var(--name)` reads a custom variable: from the
182
+ nearest `vars` (figure or plot), else a `"--name"` key of the style. The fallback is used
183
+ when the value is unset. Loops raise. Text settings (titles, labels, names, formats)
184
+ never read `var()`.
185
+ * **`calc()`** takes `+ - * /`, parentheses, numbers, dimensions with any unit, `var()`
186
+ and `inherit`: dimensions add to dimensions and multiply or divide by numbers.
187
+ * **Layout.** `%` of the axes is exact with `reference="axes"` (the axes size is given)
188
+ and resolved in each [layout](#layout) round otherwise; it is known only while the
189
+ figure is drawn. A render first resolves every other setting of the figure once (the values
190
+ drawing reads); settings set while it runs take effect at once. `spacing`, `margin` and fixed `widths`/`heights` in `%` of the figure are solved
191
+ exactly when the figure size follows from its contents.
192
+ * **Scaling.** `Figure.scaling` multiplies every absolute length (px and physical units)
193
+ wherever it is given: on objects, in styles, in `DEFAULTS`; not the figure size.
194
+ `em`, `rem` and font keywords follow `font_size`, which is scaled; `%`, `fr` and `data`
195
+ are not scaled.
196
+ * **Reading.** `get(name)` returns the value as given, `resolve(name)` the final value
197
+ (`resolve(name, of=…)` for settings whose `%` reference the caller passes), and
198
+ `explain(name)` a trace:
199
+
200
+ #### Referents
201
+
202
+ What `%` of a length can be of, besides another setting (the tables name it per setting):
203
+
204
+ <!-- settings:referents -->
205
+ | Key | `%` of |
206
+ |---|---|
207
+ | `em` | the font size |
208
+ | `axes_width` | the axes width |
209
+ | `axes_height` | the axes height |
210
+ | `across` | the axes side across the axis |
211
+ | `along` | the axes side along the axis |
212
+ | `axes` | the axes width (across) or height (down) |
213
+ | `axes_length` | the axes length along the axis |
214
+ | `data_range` | the axis range |
215
+ | `bar_across` | the axes side across the colorbar |
216
+ | `bar_thickness` | the span along a key, the axes side across a bar |
217
+ | `bar_along` | the span along the colorbar (the axes side of an attached one) |
218
+ | `figure` | the figure width (across) or height (down) |
219
+ | `slot` | the slot: one category, or the smallest gap between positions |
220
+ | `slot_part` | each series' part of a shared slot |
221
+ | `box_width` | the box width |
222
+ | `radius` | the radius |
223
+ <!-- /settings -->
224
+
225
+ #### Setting groups
226
+
227
+ Members, their names under a prefix `{p}`, and the group defaults (`"Group.member"` keys).
228
+ `"FillStyle.fill"` sets every series fill (bars, boxes, violins, pies, densities,
229
+ contours, genome signals and intervals); `"Marker.fill"` every marker fill.
230
+
231
+ <!-- settings:groups -->
232
+ | Group | Member | Under a prefix `{p}` | Default |
233
+ |---|---|---|---|
234
+ | `Font` | `font_size` | `{p}font_size` | inherited |
235
+ | `Font` | `font_family` | `{p}font_family` | inherited |
236
+ | `Font` | `font_stretch` | `{p}font_stretch` | inherited |
237
+ | `Font` | `font_variations` | `{p}font_variations` | inherited |
238
+ | `Font` | `font_optical_sizing` | `{p}font_optical_sizing` | inherited |
239
+ | `Font` | `line_height` | `{p}line_height` | inherited |
240
+ | `Font` | `markup` | `{p}markup` | inherited |
241
+ | `TextStyle` | `font_size` | `{p}font_size` | '1em' |
242
+ | `TextStyle` | `font_weight` | `{p}weight` | 'normal' |
243
+ | `TextStyle` | `font_style` | `{p}style` | 'normal' |
244
+ | `TextStyle` | `color` | `{p}color` | 'var(text_color)' |
245
+ | `Stroke` | `color` | `{p}color` | — |
246
+ | `Stroke` | `line_width` | `{p}width` | 0.5 |
247
+ | `Stroke` | `line_style` | `{p}style` | 'solid' |
248
+ | `Stroke` | `cap` | `{p}cap` | 'butt' |
249
+ | `Stroke` | `join` | `{p}join` | 'round' |
250
+ | `Marker` | `marker` | `marker (never prefixed)` | 'circle' |
251
+ | `Marker` | `size` | `{p}size` | 4.5 |
252
+ | `Marker` | `color` | `{p}color` | — |
253
+ | `Marker` | `edge_color` | `{p}edge_color` | 'auto' |
254
+ | `Marker` | `edge_width` | `{p}edge_width` | 0.5 |
255
+ | `Marker` | `fill` | `{p}fill` | True |
256
+ | `Marker` | `size_basis` | `size_basis (never prefixed)` | 'area' |
257
+ | `FillStyle` | `fill` | `{p}fill` | — |
258
+ | `NumberFormat` | `decimal_separator` | `{p}decimal_separator` | inherited |
259
+ | `NumberFormat` | `thousands_separator` | `{p}thousands_separator` | inherited |
260
+ | `NumberFormat` | `minus` | `{p}minus` | inherited |
261
+ | `NumberFormat` | `prefix` | `{p}prefix` | inherited |
262
+ | `NumberFormat` | `suffix` | `{p}suffix` | inherited |
263
+ | `NumberFormat` | `precision` | `{p}precision` | inherited |
264
+ <!-- /settings -->
265
+
266
+ ```
267
+ >>> pl.Plot(style="matplotlib").x_axis.explain("tick_spacing")
268
+ Axis.tick_spacing = (46.6667px, 33.3333px) ← ('calc(3.5 * var(tick_label_font_size))', 'calc(2.5 * var(tick_label_font_size))') (default Axis.tick_spacing)
269
+ Axis.tick_label_font_size = 13.3333px ← '1em' (default Axis.tick_label_font_size)
270
+ Axis.font_size = 13.3333px ← '10.0pt' (inherited from Figure: style "matplotlib" font_size)
271
+ ```
272
+
273
+ ## 2. Figures
274
+
275
+ ```python
276
+ pl.Figure(**settings)
277
+ fig.plot(id=None, **settings) # the plot with id (created if needed), or the next one
278
+ fig.scatter(x, y, **settings) # any plot type: a new plot holding it
279
+ fig.title(text, **settings) # figure title
280
+ fig.add_title(text, plots=None, side="top", **settings) # another, over plots
281
+ fig.add_legend(plots=None, side="right", **settings) # a legend of plots' entries
282
+ fig.x_axis(**settings) # settings of every plot's x axis (fig.y_axis: y)
283
+ fig.add_colorbar(source=None, plots=None, side="bottom", **settings) # beside plots
284
+ fig.colorbar(source, id=None, **settings) # the guide of a color axis, in its own area
285
+ fig.color_axis(**settings) # a shared color axis (fig.size_axis: size)
286
+ fig.size_legend(source, id=None, values=None, title=None)
287
+ fig.track(**settings) # a new track (layout="tracks")
288
+ fig.vline(x, rows=None, **settings) # through plots and the gaps between them
289
+ fig.vspan(x0, x1=None, rows=None, **settings)
290
+ fig.group(first, last=None, label=None, letter=None)
291
+ fig.plots # plots in creation order
292
+ fig.titles, fig.legends, fig.colorbars # figure titles (main first), legends, colorbars
293
+ ```
294
+
295
+ A plot type called on the figure (`fig.scatter(…)`, `fig.hist(…)`, `fig.bigwig(…)`) makes
296
+ a new plot holding it and returns the series: the plot's settings that the plot type
297
+ lacks, `title`, `x_axis` and `y_axis` go to the plot.
298
+
299
+ ### Arrangement
300
+
301
+ * **Grid.** `layout=[[1, 1, 2], [3, 3, 2]]`: each id covers a rectangle of cells; `0` or
302
+ `None` leaves a cell empty. An id holds a plot or a colorbar. `fig.plot()` returns the
303
+ next id without a plot, in reading order.
304
+ * **Automatic** (`layout="auto"`, the default). Plots take positions in creation order:
305
+
306
+ | Settings | Arrangement |
307
+ |---|---|
308
+ | `cols=4` | row by row, at most 4 per row |
309
+ | `rows=4` | column by column, at most 4 per column |
310
+ | `rows=2, cols=3` | a fixed 2 × 3 grid, row by row (full: `ValueError`) |
311
+ | neither | ⌈√n⌉ columns, row by row, chosen when drawn (adding plots can move earlier ones) |
312
+
313
+ `fill_order` (`"row"` or `"col"`) overrides the fill direction. In automatic arrangement ids
314
+ are names; `fig.plot()` gives 1, 2, 3, … skipping taken ids.
315
+
316
+ * **Tracks.** `layout="tracks"`: one column of plots top to bottom in creation order
317
+ (`cols` 1), sharing x (`share_x="all"`), `spacing` 0 and `width` 480 px unless given;
318
+ each row is as high as its plot's `height` (a [track](#tracks)'s: a length, a share such
319
+ as `"1fr"`, or from its content), other plots `1fr`. New plots are tracks
320
+ (`fig.plot()`, `fig.track()`, `fig.bigwig(…)`). `pl.Tracks(region)` is this layout with
321
+ a genome x axis ([§9](#9-genome-tracks)).
322
+
323
+ ### Sizes and alignment
324
+
325
+ * `width` × `height` is the size of the box `reference` names:
326
+ * `"axes"` (default): each grid cell's axes rectangle; the figure size follows;
327
+ * `"plot"`: each cell's whole plot box (axes and decorations); the figure size follows;
328
+ * `"figure"`: the whole figure; the cells share what the decorations leave.
329
+
330
+ With only one of `width` and `height`, `aspect_ratio` (width / height, default 5/4)
331
+ gives the other; with neither, the default is 150 × 120 px. Giving all
332
+ three raises `ValueError`. Plots with a `data_ratio` (and pies) take the other side from
333
+ it when only `width` or only `height` is given. `widths`/`heights` are the columns' and
334
+ rows' ratios (numbers or `fr`), or fixed lengths (`["2in", "1fr", "1fr"]`) that the
335
+ ratios share the rest around; a plot spanning cells gets their sizes plus the gaps
336
+ between them.
337
+ * `align="axes"` (default): axis lines line up. Between columns the gutter holds the
338
+ widest right margin before it, the widest left margin after it and `spacing`.
339
+ * `align="borders"`: plot boxes (axes and decorations) line up, and each plot's axes are
340
+ what its own decorations leave.
341
+ * `reference` and `align` combine:
342
+
343
+ | `align` \ `reference` | `"axes"` | `"plot"` | `"figure"` |
344
+ |---|---|---|---|
345
+ | `"axes"` | each cell's axes are `width` | the widest plot box of a column (axes plus the column's largest margins) is `width`; the axes are what is left | the figure is `width`; the axes share what the gutters leave |
346
+ | `"borders"` | a column's box is `width` plus the largest margins in it, so every axes rectangle is at least `width` | each cell's box is `width` | the figure is `width`; the boxes share what the gaps leave |
347
+
348
+ * Columns (rows) holding only vertical (horizontal) colorbars are as wide as the bar (a
349
+ key: as wide as it is), unless `widths` (`heights`) is given.
350
+ * Margins come from the real text metrics of tick labels, axis labels, titles, outside
351
+ legends and attached colorbars ([layout](#layout)).
352
+
353
+ ### Layout
354
+
355
+ * **Bands.** A plot is its axes rectangle with four stacks of bands around it, from the
356
+ axes outward: tick marks, tick labels, the ×10ᵏ offset (above the y axis), the axis
357
+ label, twin axes, an outside legend, attached colorbars, the plot's titles and (on top)
358
+ the plot's `space_above`; outermost on the left, the row label band and the band of
359
+ [group](#rows) letters, as wide as the widest of the plot's grid column. Each band has a thickness and an overhang along its
360
+ side (tick labels past the ends of the axis, a wide title). A side's margin is its
361
+ bands' thicknesses, at least the overhangs of the bands across it. Bands stack: each
362
+ starts past the ones before it (mirrored ticks included), the titles past everything on
363
+ their side; only twin axes are drawn at the axes edge.
364
+ * **Grid.** Each line between cells takes the largest margin of the plots there
365
+ (`align="axes"`), or each plot's axes are what its margins leave of its box
366
+ (`"borders"`). Colorbars and size legends in their own areas are cells of the grid; the
367
+ figure title is a band at the top of the figure, and the other figure titles, the
368
+ figure legends and colorbars and the groups' labels sit in lanes in the lines between
369
+ cells ([figure title](#figure-title)).
370
+ * **Rounds.** Only what is circular is repeated: an axis' length sets its ticks, whose
371
+ labels set the margins, which (with `reference="plot"` or `"figure"`) set the length;
372
+ `data_ratio`; stats binned at the axes' resolution ([hexbin](#hexbin), genome
373
+ [bins](#9-genome-tracks)); the figure title's band in a figure of fixed height; the
374
+ lanes of figure titles that wrap to the width of the plots they cover. A round
375
+ measures every plot for its axes size and solves the grid. Rounds stop when no axes size
376
+ moves by more than 1/3 px; after 5, a layout still moving (between two tick sets) keeps
377
+ the last. With `reference="axes"` one round suffices. `position="auto"` legends are
378
+ placed on the occupancy grid of the placed axes; one moved outside takes a round more.
379
+ * **Geometry.** The layout ends in a frozen geometry: every axes rectangle, tick mark,
380
+ text run, legend entry and colorbar in px. Drawing reads it and measures nothing: a text
381
+ run holds its shaped line (shaped once per content and font, memoized in the font
382
+ database), which is what is drawn; figure titles on top and bottom are laid out once as
383
+ paragraphs.
384
+ * **One plot.** `p.save()` lays out the whole figure and keeps the plot at its size in it:
385
+ its axes (`align="axes"`), or its box (`"borders"`: the axes are what its own margins
386
+ leave), with its outer tick labels, its own row label band, its own titles and its
387
+ whole legend and its attached colorbars (figure titles, legends and colorbars are left
388
+ out).
389
+
390
+ ### Figure title
391
+
392
+ ```python
393
+ fig.title(text, **settings) # None removes it
394
+ ```
395
+
396
+ ```python
397
+ fig.add_title("Treated", plots=[a, b], side="top", **settings) # returns it
398
+ fig.titles # the main title first
399
+ ```
400
+
401
+ The main title is a band at the top of the figure: the title's height (all lines,
402
+ wrapped within its width) plus `pad`. The figure grows by the band, except with
403
+ `reference="figure"`, where the plots shrink by it. `over="axes"` aligns it within the
404
+ leftmost to rightmost axes (a start-aligned title starts at the first y axis line),
405
+ `"plot"` within their boxes, `"figure"` within the figure minus `margin`. Rich content
406
+ styles a second line (`["Title\n", pl.Span("subtitle", font_size=7,
407
+ font_weight="normal")]`). It is drawn last and is not part of `Plot.save`. `title=` given
408
+ to `pl.Plot` sets the plot title. `rule` draws a line `rule_width` thick across its width:
409
+ `"outside"` above the title (The Economist's red bar, in the `economist` style), `True`
410
+ between the title and the plots.
411
+
412
+ `fig.add_title` makes a title over a set of plots (plots or their series, as
413
+ `fig.group` takes them; default every plot), which covers the grid rectangle of their
414
+ cells: a plot inside that rectangle but not given is an error naming it. Figure titles
415
+ share the settings of plot titles ([title](#title)).
416
+
417
+ ```python
418
+ fig.add_title("Sites", plots=[a, b, c])
419
+ fig.add_title("Treated", plots=[a, b]) # nested: under "Sites"
420
+ fig.add_title("Control", plots=[d, e], rule=True) # beside another span: same lane
421
+ fig.add_title("Batch 1", plots=[a, d], side="left")
422
+ ```
423
+
424
+ * **Lanes.** A figure title sits in the line between cells beside the plots it covers: a
425
+ top title above its topmost row, a bottom one below its bottommost, a left or right one
426
+ beside its first or last column. The titles of one side of a line stack outward from
427
+ the plots: a title whose plots are a subset of another's is nearer, titles over
428
+ disjoint spans share a lane, overlapping ones take lanes in creation order; `order`
429
+ overrides (lower nearer; unset counts as the lane the rules give): a title sits past
430
+ every lane of a lower order, and titles of one order share a lane where their spans
431
+ are disjoint. A lane is as thick
432
+ as its thickest title: `pad`, the text, and `rule_width + rule_gap` with a rule. Plot
433
+ titles are inside the plots' boxes, nearer than any figure title. Figure legends and
434
+ colorbars take lanes too ([figure legends](#figure-legends), [colorbars](#colorbars));
435
+ over the same plots, from the plots outward: legend, colorbar, title.
436
+ * **Gaps.** The gap at a line between rows (columns) is `spacing` plus its lanes, along
437
+ the whole line, so the titles in it line up. On the figure's edge, the lanes come between
438
+ two `margin`s, one at the edge and one between them and the plots, as the main title's
439
+ band does. With `reference="figure"` the plots shrink by the lanes; otherwise the
440
+ figure grows.
441
+ * **Text.** Titles on top and bottom wrap to their span (`over`); titles on the left and
442
+ right do not (`\n` starts a line) and read upward on the left, downward on the right.
443
+ * A [group](#rows)'s `label` is a left figure title over its plots.
444
+ * The main title is the outermost lane of the top, over every plot. On another side,
445
+ rotated, or with an `order`, it is laid out in the lanes as the others are.
446
+ Style keys `"MainTitle.name"` apply to it alone, `"FigureTitle.name"` to every figure
447
+ title.
448
+ * `p.save()` (one plot alone) leaves out the figure titles, legends and colorbars.
449
+
450
+ <!-- settings:FigureTitle -->
451
+ | Setting | Default | Meaning |
452
+ |---|---|---|
453
+ | `text` | — | Title text: a string or rich content; `\n` starts a line. |
454
+ | `side` | 'top' | `top`, `bottom`, `left` or `right`. |
455
+ | `align` | 'center' | Alignment along the side: `start`, `center`, `end` (`left` and `right`: `start` and `end`); along the left and right sides, `start` is where rotated text begins (the bottom at 90, the top at −90 and 0). |
456
+ | `over` | 'axes' | Span it is aligned and wrapped within: from the first to the last axes of its plots, their boxes, or the whole figure. |
457
+ | `rotation` | 'auto' | `auto`: 0 on top and bottom, 90 on the left (reads upward), −90 on the right (reads downward); or 0, 90, −90. |
458
+ | `pad` | '0.5em' | Gap between the title and the plots. Length. |
459
+ | `order` | — | Place in its side's lanes: lower is nearer the plots; unset: a title nested in another nearer, then creation order. |
460
+ | `rule` | False | A line along the span: `True` or `"inside"` between the title and what it covers, `"outside"` beyond the title, `False` none. |
461
+ | `rule_color` | 'var(color)' | Color of the rule. |
462
+ | `rule_width` | 'var(line_width)' | Thickness of the rule. Length. |
463
+ | `rule_gap` | '0.5em' | Gap between the rule and the title. Length; `%`: of the font size. |
464
+ | `font_size` | '1em' | Font size; default the base font size. Length; `%`: of the parent's font size. |
465
+ | `font_weight` | 'bold' | `normal`, `bold` or a weight 1–1000. |
466
+ | `font_style` | 'normal' | `normal`, `italic`, `oblique` or `"oblique 10deg"`. |
467
+ | `color` | 'var(text_color)' | Text color. |
468
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
469
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
470
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
471
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
472
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
473
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
474
+
475
+ Groups: `TextStyle`, `Font`.
476
+ <!-- /settings -->
477
+
478
+ ### Shared axes
479
+
480
+ ```python
481
+ fig = pl.Figure(cols=3, share_x="col", share_y="row")
482
+ fig = pl.Figure(cols=3, share="grid") # the same
483
+ q = fig.plot(share_x=p) # q's x axis joins p's group
484
+ ```
485
+
486
+ `share_x`, `share_y`: `False` (default), `True`/`"all"` (every plot), `"col"` (plots with
487
+ the same column span) or `"row"` (the same row span). `share` sets both; `"grid"` means x
488
+ per column and y per row. A plot's own `share_x`, `share_y` or `share` (another plot)
489
+ overrides the figure's groups for it; groups chain. Colorbars and plots without axes are
490
+ never in a group. `share_color` and `share_size` group plots the same way for their
491
+ series' color and size axes ([color and size axes](#6-color-and-size-axes)), and
492
+ `share_legend` for one legend of their entries ([figure legends](#figure-legends)).
493
+
494
+ Within a group the scale (which must be equal), the limits (from all members' series,
495
+ then padding, `include_zero` and `snap`; one explicit `limits` applies to the group, two
496
+ different ones are an error), inversion, ticks and category order (first appearance, in
497
+ plot order) are shared; titles, grid, spines and colors stay per plot. With
498
+ `label_outer` (default for figure-level groups), tick labels and axis titles are drawn
499
+ only on the bottom plot of each column (x; top for `side="top"`) and the left plot of
500
+ each row (y; right for `side="right"`); ticks stay on every plot and inner gutters
501
+ shrink. `Plot.save` of a member keeps the group's limits and shows its labels.
502
+
503
+ ### Figure axes
504
+
505
+ ```python
506
+ fig.x_axis(label="Time (s)", tick_format="int") # every plot's x axis
507
+ fig.y_axis(scale="log10")
508
+ ```
509
+
510
+ `fig.x_axis` and `fig.y_axis` hold settings that every plot's x (y) axis takes unless the
511
+ axis has its own: they come right after the axis' own values in the cascade
512
+ ([§1](#1-conventions)), so they beat styles and defaults. Twins' axes take them too; color
513
+ and size axes do not.
514
+
515
+ ### Rows
516
+
517
+ ```python
518
+ p = fig.plot(y_axis={"label": "Control", "label_position": "band"}) # a row label
519
+ fig.group(p, q, label="Treated", letter="B") # plots p to q (creation order)
520
+ fig.vline(0, rows=[p, q]) # through p, q and the gap between them
521
+ fig.vspan(-1, 1) # under every plot
522
+ ```
523
+
524
+ * **Row labels.** The y axis' `label` with `label_position` `"band"` (rotated) or
525
+ `"left"` (horizontal, right-aligned) sits in a band left of the plot instead of beside
526
+ the tick labels; `"inside"` puts it inside the axes at the top left; `\n` starts a line.
527
+ The band is as wide as the widest label of the plots starting in the same grid column,
528
+ and the labels line up at the widest y axis margin of that column. A plot has one y
529
+ label: beside its axis or in the band. Tracks put theirs in the band. A plot's
530
+ `space_above` adds space above it.
531
+ * **Groups.** `fig.group(first, last=None, **settings)`: plots `first` to `last` (plots
532
+ or their series, in creation order). Its `label` is a left [figure title](#figure-title)
533
+ over them, reading upward, centered on their axes, in the group's font settings
534
+ (`font_size`, `font_family`, `text_color`, `markup`; normal weight) and `pad` from the
535
+ plots; it is made at each layout, in the group's creation order, and is not in
536
+ `fig.titles`. The plots must fill the grid rectangle they span. A bold panel `letter`
537
+ sits in a band left of the row labels, level with the top of the first plot's axes.
538
+ With a shared x axis and `label_outer`, the group's last plot shows the tick labels too
539
+ (the axis title stays under the bottom plot). `p.save()` leaves out the label, as other
540
+ figure titles.
541
+ * **Lines and bands.** `fig.vline(x, rows=None)` and `fig.vspan(x0, x1, rows=None)` run
542
+ from the top of the first of the plots `rows` (a plot, a series, or a list; all by
543
+ default) to the bottom of the last one, gaps included, in each grid column; `x` is in
544
+ the drawn units of the first plot's x axis. Bands are drawn under the plots, lines over
545
+ them. `fig.vspan(region)` takes a genome region (`"chr1:1,400,001-1,450,000"`, a
546
+ `(chr, start, end)` tuple) as positions, less the x axis' `origin`.
547
+
548
+ FigureVLine:
549
+
550
+ <!-- settings:FigureVLine -->
551
+ | Setting | Default | Meaning |
552
+ |---|---|---|
553
+ | `color` | '#4d4d4d' | Line color. |
554
+ | `line_width` | inherited (0.5) | Line width. Length. |
555
+ | `line_style` | 'dashed' | `solid`, `dashed`, `dotted`, `dashdot` or a dash list. Length. |
556
+ | `alpha` | 1.0 | Opacity. |
557
+
558
+ Groups: `Stroke`.
559
+ <!-- /settings -->
560
+
561
+ FigureVSpan:
562
+
563
+ <!-- settings:FigureVSpan -->
564
+ | Setting | Default | Meaning |
565
+ |---|---|---|
566
+ | `color` | '#e5e5e5' | Fill color. |
567
+ | `alpha` | 1.0 | Opacity. |
568
+ <!-- /settings -->
569
+
570
+ FigureGroup:
571
+
572
+ <!-- settings:FigureGroup -->
573
+ | Setting | Default | Meaning |
574
+ |---|---|---|
575
+ | `label` | — | Group label: a left figure title over the group's plots, reading upward, centered on their axes. |
576
+ | `letter` | — | Panel letter at the group's top left, left of the row labels. |
577
+ | `font_size` | '1em' | Font size of the label. Length; `%`: of the parent's font size. |
578
+ | `letter_font_size` | '1.4em' | Font size of the letter. Length; `%`: of the font size. |
579
+ | `letter_weight` | 'bold' | Weight of the letter. |
580
+ | `pad` | '0.5em' | Gap right of the letter, and the label's `pad` (its gap to the plots). Length; `%`: of the font size. |
581
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
582
+ | `text_color` | inherited ('black') | Text color. |
583
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
584
+
585
+ Groups: `TextStyle` (`letter_`), `Font`.
586
+ <!-- /settings -->
587
+
588
+ ### Facets
589
+
590
+ ```python
591
+ fig, panels = pl.facet(df, col="condition", row="replicate", colorbar="right")
592
+ panels.scatter("x", "y", c="density") # one layer per panel, on its rows
593
+ panels.hline(0, line_style="dashed") # decorations on every panel
594
+ panels.map(lambda p, rows: p.hist(rows["x"])) # anything, per panel
595
+ fig.save("facets.pdf")
596
+ ```
597
+
598
+ `pl.facet(data, col=None, row=None, wrap=None, share="grid", order=None,
599
+ title_format="{name} = {value}", colorbar=None, **figure_settings)` returns an ordinary
600
+ `Figure`, with one plot per combination of `row` and `col` values (first-appearance or
601
+ categorical order; `order={column: [values]}`) in a grid, and the `FacetSet` of those
602
+ panels. `wrap` wraps `col` alone into rows of that many panels. Panels are titled by
603
+ `title_format`.
604
+
605
+ * **Layers.** A plot type called on the set (`panels.scatter(…)`, any registered one)
606
+ calls it on every panel with `data=` the panel's rows and returns a `LayerSet` (a list
607
+ of the series; `.set(**settings)` sets them all, `.plots` their plots). Group levels
608
+ (`group=`) get the same colors in every panel. Decorations (`hline`, `vline`, `axline`,
609
+ `hspan`, `vspan`, `text`, `annotate`) go on every panel.
610
+ * **Shared axes** are the figure's ordinary options: `share` (default `"grid"`: x per
611
+ column, y per row, outer labels only), `share_color` (default `"all"`: the panels'
612
+ color axes train as one; a `color_map`, `color_limits` or `color_scale` given to the
613
+ call goes to each series alike) and `share_size` (default `"all"`: one size axis, so
614
+ one size key) and `share_legend` (default `"all"`: one legend for the panels' entries,
615
+ on the right, [figure legends](#figure-legends)).
616
+ * **Colorbar.** `colorbar="right"`, `"left"`, `"top"` or `"bottom"` adds a column (or a
617
+ row, with a horizontal colorbar) to the grid, holding the colorbar of the first call that maps
618
+ colors (`panels.colorbar`): the guide of the panels' shared color axis.
619
+ * `panels.panels` maps facet keys (a value, or `(row value, col value)`) to plots;
620
+ `panels.plot(key)` returns one; iterating the set gives the plots; `panels.subsets()`
621
+ gives `(key, plot, rows)`.
622
+
623
+ ### Settings
624
+
625
+ <!-- settings:Figure -->
626
+ | Setting | Default | Meaning |
627
+ |---|---|---|
628
+ | `layout` | 'auto' | `auto`: plots in automatic rows and columns (`rows`, `cols`, `fill_order`); rows of ids (`[[1, 1, 2], [3, 4, 2]]`): each id covers a rectangle of cells, `0`/`None` leaves a cell empty; `tracks`: one column of plots top to bottom in creation order, sharing x, each row as high as its plot's `height` (tracks: from their content; other plots `1fr`). |
629
+ | `rows` | — | Automatic arrangement: rows. |
630
+ | `cols` | — | Automatic arrangement: columns. |
631
+ | `fill_order` | 'auto' | Fill order of the automatic arrangement: `auto` (row by row with `cols`, column by column with `rows`), `row` or `col`. |
632
+ | `align` | 'axes' | `axes`: axis lines line up across plots; `borders`: plot boxes line up. |
633
+ | `widths` | — | Column widths: ratios (numbers or `fr`) sharing the room left by fixed lengths (`"2in"`, `"30%"` of the figure width). |
634
+ | `heights` | — | Row heights, as `widths`. |
635
+ | `width` | '150px' | Width of the `reference` box: one cell's axes, one cell's plot, or the figure. Length. |
636
+ | `height` | 'calc(var(width) / var(aspect_ratio))' | Height of the `reference` box. Length. |
637
+ | `aspect_ratio` | 1.25 | Width / height of the `reference` box (16:9 → `16 / 9`), when only one of `width` and `height` is given. |
638
+ | `reference` | 'axes' | What `width` and `height` measure: `axes` (each grid cell's axes rectangle), `plot` (each cell's whole plot box) or `figure`. |
639
+ | `spacing` | 13.0 | Minimum gap between neighbouring plots. Length; `%`: of the figure width (across) or height (down). |
640
+ | `margin` | 5.0 | Space around the figure. Length; `%`: of the figure width (across) or height (down). |
641
+ | `background` | 'white' | Figure background, default white; `None` or `"none"`: transparent (white in JPEG, which has no transparency). |
642
+ | `dpi` | 384.0 | Resolution of PNG, JPEG, JPEG XL and AVIF output: `96` gives one image pixel per px, the default `384` four; up to 16, a multiple of 96 (`2` is 192). |
643
+ | `quality` | 'auto' | Quality (1–100), as vec_io's: of PNG output (a lossy palette of at most 256 colors), JPEG, JPEG XL and AVIF output, and of rasterized content in PDFs (stored as JPEG); `"lossless"` (not JPEG); `"auto"`: 90 for PNG and JPEG, lossless for JPEG XL, AVIF and PDF content. |
644
+ | `share_x` | — | Plots sharing their x axis: `False`, `True`/`"all"`, `"col"` (same column span) or `"row"` (same row span). |
645
+ | `share_y` | — | Plots sharing their y axis, as `share_x`. |
646
+ | `share` | — | Both axes at once: as `share_x`, or `"grid"` (x per column, y per row); `share_x`/`share_y` override it. |
647
+ | `share_color` | False | Plots whose series' own color axes are one (limits over all their values), as `share_x`. |
648
+ | `share_size` | False | Plots whose series' own size axes are one (limits over all their values, one size key), as `share_x`. |
649
+ | `share_legend` | False | Legends shared by plots, made by the figure: `False`, `True`/`"all"` (one on the right of the figure), `"row"` (one on the right of each row), `"col"` (one at the bottom of each column). |
650
+ | `label_outer` | — | Tick labels and axis titles of shared axes only on the outer plots (bottom of each column, left of each row); default `True` for groups from the figure's settings, `False` for plots paired with `share_x=plot`. |
651
+ | `style` | — | A style name (`"ggplot2"`, …) or a dict of settings with an optional `"base"`; default: the session style (`set_style`, `use_style`), else `"default"`. |
652
+ | `vars` | — | Custom variables, read by `var(--name)` in any setting here and below: `{"accent": "#c00"}`. |
653
+ | `scaling` | 1.0 | Multiplies every font size, line width, marker size, tick length and pad of the style; default 1. |
654
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
655
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
656
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
657
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
658
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
659
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
660
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
661
+ | `text_color` | inherited ('black') | Text color. |
662
+ | `line_width` | inherited (0.5) | Default line width. Length. |
663
+ | `palette` | inherited ('tab10_custom') | Colors of series without one. |
664
+ | `alpha` | inherited (1.0) | Default opacity of series. |
665
+ | `rasterize` | inherited (False) | `True` or a dpi: series drawn as images inside the PDF. |
666
+ | `simplify` | inherited ('auto') | vec_io's `simplify` for every series; default `"auto"`. |
667
+ | `data` | inherited (None) | A table whose columns the series' data arguments name. |
668
+ | `color_map` | inherited ('rainbow_llhh') | Default color map (alias `cmap`): of heatmaps, contours and numbers given as colors. |
669
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
670
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
671
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
672
+ | `prefix` | inherited ('') | Text before every number. |
673
+ | `suffix` | inherited ('') | Text after every number. |
674
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
675
+
676
+ Groups: `Font`, `NumberFormat`.
677
+ <!-- /settings -->
678
+
679
+ ## 3. Plots
680
+
681
+ ```python
682
+ pl.Plot(figure=None, id=None, **settings) # title="…", x_axis={…}, y_axis={…}
683
+ p.scatter(x, y, **s) p.line(x, y=None, **s) p.fill(x, y1, y2=0, **s)
684
+ p.box(values, **s) p.heatmap(values, **s) p.colorbar(source=None, **s)
685
+ p.title(text, **s) p.x_axis(label, **s) p.y_axis(label, **s) p.legend(position, **s)
686
+ p.add_title(text, side="top", **s) # another title, returned
687
+ p.series p.titles p.colorbars p.figure p.id
688
+ ```
689
+
690
+ `p.title`, `p.x_axis`, `p.y_axis` and `p.legend` are objects; calling one sets its
691
+ settings and returns it. At creation (and in `p.set`), `title=` sets the title text and
692
+ `x_axis={…}`, `y_axis={…}` set the axes' settings: `pl.Scatter(x, y, x_axis={"scale":
693
+ "log"})`, `fig.bigwig(reader, y_axis={"label": "ATAC"})`. Series are drawn in `z` order (default: call order) inside the
694
+ axes clip.
695
+
696
+ <!-- settings:Plot -->
697
+ | Setting | Default | Meaning |
698
+ |---|---|---|
699
+ | `spines` | 'bottom left' | Axis lines drawn: any of `left`, `bottom`, `right`, `top`, or `all`, `none`. |
700
+ | `data_ratio` | — | Data aspect ratio: 1 makes one unit as long on both axes. |
701
+ | `background` | — | Background color of the axes area. |
702
+ | `border_color` | — | Color of a frame around the axes area (drawn under the axis lines); default none. |
703
+ | `border_width` | 0.5 | Width of the frame. Length. |
704
+ | `clip` | True | Clip series to the axes area. |
705
+ | `axes` | True | Draw axes; `False` hides both axes, drops padding and fixes the aspect to 1 (set by pie charts). |
706
+ | `share_x` | — | Another plot of the figure whose x axis this plot shares (groups chain); overrides the figure's `share_x`. |
707
+ | `share_y` | — | Another plot whose y axis this plot shares. |
708
+ | `vars` | — | Custom variables, read by `var(--name)` in any setting here and below: `{"accent": "#c00"}`. |
709
+ | `share` | — | Another plot whose x and y axes this plot shares. |
710
+ | `space_above` | 0.0 | Space above the plot, beyond the figure's `spacing`. Length; `%`: of the font size. |
711
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
712
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
713
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
714
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
715
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
716
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
717
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
718
+ | `text_color` | inherited ('black') | Text color. |
719
+ | `line_width` | inherited (0.5) | Default line width. Length. |
720
+ | `palette` | inherited ('tab10_custom') | Colors of series without one. |
721
+ | `alpha` | inherited (1.0) | Default opacity of series. |
722
+ | `rasterize` | inherited (False) | `True` or a dpi: series drawn as images inside the PDF. |
723
+ | `simplify` | inherited ('auto') | vec_io's `simplify` for every series: `"auto"`, `True`, a dpi or `False`. |
724
+ | `color_map` | inherited ('rainbow_llhh') | Default color map (alias `cmap`): of heatmaps, contours and numbers given as colors. |
725
+ | `data` | inherited (None) | A table (dict, pandas or polars data frame, numpy structured array): strings in the data arguments of series name its columns. |
726
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
727
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
728
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
729
+ | `prefix` | inherited ('') | Text before every number. |
730
+ | `suffix` | inherited ('') | Text after every number. |
731
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
732
+
733
+ Groups: `Stroke` (`border_`), `Font`, `NumberFormat`.
734
+ <!-- /settings -->
735
+
736
+ ### Title
737
+
738
+ ```python
739
+ p.title("Yield") # the main title
740
+ p.add_title("Subtitle", order=-1) # between the main title and the axes
741
+ p.add_title("n = 120", side="bottom", align="start")
742
+ p.add_title("Batch 1", side="left", rule=True)
743
+ ```
744
+
745
+ A plot has a main title (`p.title`) and any number of others (`p.add_title`, which
746
+ returns the title; `p.titles` lists them, main first), each on a `side` of the plot.
747
+ The titles of one side stack outward from the axes, outermost of the side's bands (past
748
+ the axis, twin axes, an outside legend and attached colorbars): the main title nearest,
749
+ then the others in creation order; `order` places a title elsewhere, lower nearer
750
+ (`order=-1`: a subtitle between the main title and the axes). Each takes a band of its
751
+ `pad`, its text across the side and, with a `rule`, `rule_width + rule_gap`; the rule runs
752
+ along its span (`over`). `\n` starts a line, `line_height` apart; the last line is
753
+ nearest the axes on top and on the left and right, the first at the bottom. Left titles
754
+ read upward, right titles downward (`rotation="auto"`); `rotation=0` sets them
755
+ horizontal, beside the axes.
756
+
757
+ <!-- settings:Title -->
758
+ | Setting | Default | Meaning |
759
+ |---|---|---|
760
+ | `text` | — | Title text: a string or rich content; `\n` starts a line. |
761
+ | `side` | 'top' | `top`, `bottom`, `left` or `right`. |
762
+ | `align` | 'center' | Alignment along the side: `start`, `center`, `end` (`left` and `right`: `start` and `end`); along the left and right sides, `start` is where rotated text begins (the bottom at 90, the top at −90 and 0). |
763
+ | `over` | 'axes' | Span the title is aligned within: the axes, or the axes and the axis labels beside them (the y axis' on top and bottom, the x axis' on the left and right). |
764
+ | `rotation` | 'auto' | `auto`: 0 on top and bottom, 90 on the left (reads upward), −90 on the right (reads downward); or 0, 90, −90. |
765
+ | `pad` | 5.0 | Gap between the title and what it covers. Length; `%`: of the axes height. |
766
+ | `order` | — | Place in its side's stack: lower is nearer; unset: the main title nearest, then the others in creation order. |
767
+ | `rule` | False | A line along the span: `True` or `"inside"` between the title and what it covers, `"outside"` beyond the title, `False` none. |
768
+ | `rule_color` | 'var(color)' | Color of the rule. |
769
+ | `rule_width` | 'var(line_width)' | Thickness of the rule. Length. |
770
+ | `rule_gap` | '0.5em' | Gap between the rule and the title. Length; `%`: of the font size. |
771
+ | `font_size` | '1em' | Font size; default the base font size. Length; `%`: of the parent's font size. |
772
+ | `font_weight` | 'normal' | `normal`, `bold` or a weight 1–1000. |
773
+ | `font_style` | 'normal' | `normal`, `italic`, `oblique` or `"oblique 10deg"`. |
774
+ | `color` | 'var(text_color)' | Text color. |
775
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
776
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
777
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
778
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
779
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
780
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
781
+
782
+ Groups: `TextStyle`, `Font`.
783
+ <!-- /settings -->
784
+
785
+ ### Legend
786
+
787
+ One entry per series with a `name`, drawn as the series draws itself (marker, line,
788
+ swatch or box), or with `glyph="box"`, `"circle"` or `"line"` in the series color. At
789
+ `top`, `bottom`, `outside_top` and `outside_bottom` entries are side by side unless
790
+ `orientation` or `columns` is set.
791
+
792
+ **Size keys.** A series whose `size` goes through a [size axis](#6-color-and-size-axes)
793
+ adds a size key, the axis' guide, to its plot's legend, below the series entries: the
794
+ axis' `label` (default: the `size` column name) as a header, then sample markers at their
795
+ real size with their values (the list given as the series' `size_legend`, else the axis'
796
+ `ticks`, else 3–5 nice numbers inside its limits; in its `tick_format`;
797
+ `size_legend=False` drops it). Series sharing one size axis (one `fig.size_axis()`, or own
798
+ axes trained as one by `share_size` or `group=`) share one key, in grey, also across
799
+ plots. The key goes in the legend of the rightmost of their plots, and the topmost of
800
+ those, so it sits at the figure's top right. Users with different `size_map`s get a key
801
+ per map. A single series' key takes its color (grey when its colors are mapped).
802
+ `fig.size_legend(source, id=…, values=None, title=None)` places the key of a size axis
803
+ (or of a series' one) in its own grid area, as colorbars do. It shows every series of
804
+ that axis, and no plot legend repeats it.
805
+
806
+ `auto` chooses a position once the axes are placed. Every series marks what it draws on a
807
+ 64 × 64 grid over the axes: markers (with their size), lines and curves (along their
808
+ whole length), bars, histogram bins, boxes, violins, areas and fills (the area they cover),
809
+ heatmaps, 2-D histograms and contours (the whole axes). Data are sampled beyond 50,000
810
+ points and curves thinned to 4,096 vertices (twin plots' series included). The legend
811
+ goes to the first of `top_right`, `top_left`, `bottom_left`, `bottom_right`, `top`,
812
+ `bottom`, `center_right`, `center_left` whose box covers no marked cell; else to the free
813
+ place (any position inside, one grid cell apart, covering no marked cell) nearest to a
814
+ corner of the axes; else `outside_right`, with room made in the layout, when every
815
+ candidate covers more than 2 % marked cells; else the candidate covering the fewest.
816
+
817
+ <!-- settings:Legend -->
818
+ | Setting | Default | Meaning |
819
+ |---|---|---|
820
+ | `position` | 'auto' | `auto`, `top_right`, `top_left`, `bottom_right`, `bottom_left`, `top`, `bottom`, `outside_right`, `outside_top`, `outside_bottom` or `none`. |
821
+ | `columns` | 1 | Number of columns. |
822
+ | `frame` | False | Draw a frame and background. |
823
+ | `title` | 'auto' | Legend title; `"auto"`: the `group` column name, if any. |
824
+ | `font_size` | '1em' | Font size. Length; `%`: of the parent's font size. |
825
+ | `color` | 'var(text_color)' | Text color. |
826
+ | `background` | 'white' | Background of a framed legend. |
827
+ | `frame_color` | '#999999' | Frame color. |
828
+ | `frame_width` | 0.5 | Frame line width. Length. |
829
+ | `pad` | 5.0 | Gap to the axes. Length; `%`: of the axes width (across) or height (down). |
830
+ | `frame_radius` | 0.0 | Corner radius of the frame. Length. |
831
+ | `frame_alpha` | 1.0 | Opacity of the frame and background. |
832
+ | `glyph_alpha` | — | Fill opacity of `box` and `circle` symbols, outlined in the opaque color; default: the series' own fill. |
833
+ | `glyph` | 'series' | Entry symbol: as the series draws itself, or a filled `box`, a `circle` or a `line` in the series color. |
834
+ | `orientation` | 'auto' | `horizontal`: entries side by side; `auto`: horizontal at `top`, `bottom`, `outside_top` and `outside_bottom`. |
835
+ | `glyph_length` | '1.4em' | Width of an entry's symbol. Length; `%`: of the font size. |
836
+ | `row_height` | '1.35em' | Height of an entry. Length; `%`: of the font size. |
837
+ | `glyph_gap` | '0.5em' | Gap between a symbol and its text. Length; `%`: of the font size. |
838
+ | `column_gap` | '1em' | Gap between columns. Length; `%`: of the font size. |
839
+ | `title_gap` | '0.3em' | Gap below the title. Length; `%`: of the font size. |
840
+ | `inner_pad` | 'auto' | Space inside the box; `"auto"`: 0.5em with a frame, 0.15em without. Length; `%`: of the font size. |
841
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
842
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
843
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
844
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
845
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
846
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
847
+
848
+ Groups: `TextStyle`, `Stroke` (`frame_`), `Font`.
849
+ <!-- /settings -->
850
+
851
+ #### Figure legends
852
+
853
+ ```python
854
+ fig.add_legend(plots=[a, b], side="right", **settings) # returns it
855
+ fig.add_legend() # every plot, on the right
856
+ fig.legends
857
+ fig = pl.Figure(cols=2, share_legend="row") # one legend per row
858
+ ```
859
+
860
+ A figure legend shows the entries of a set of plots (plots or their series; default every
861
+ plot) in one legend, in the lanes beside them as [figure titles](#figure-title) are: its
862
+ plots' cells must fill the grid rectangle they span (a plot inside it but not given is an
863
+ error naming it).
864
+
865
+ * **Entries.** Its plots' entries, in plot order (row by row), then in series order.
866
+ Entries with the same label and the same symbol (what the legend draws for them: kind,
867
+ colors, marker, line style and width) are one entry; the same label with another
868
+ symbol keeps both. A size key whose series' plots the legend all covers goes into it
869
+ (the first such legend), one key per shared size axis as in a plot legend.
870
+ * **Plot legends.** Its plots' legends lose those entries, and a plot left without
871
+ entries shows no legend. A plot whose `legend.position` is set keeps its legend whole
872
+ (the figure legend shows its entries too).
873
+ * **Place.** `side` (`top`, `bottom`, `left`, `right`) and `align` along the side
874
+ (`start`, `center`, `end`) within the axes of its plots, kept within the figure; the
875
+ figure grows when the legend is longer than its content. On top and bottom, entries
876
+ are side by side in rows as wide as the span (unless `columns` is set); on the left and
877
+ right, in a column (`columns`).
878
+ * **Lanes.** Legends and figure titles share the lanes and their rules (nesting, then
879
+ shared lanes for disjoint spans, then creation order; `order` overrides); over the same
880
+ plots, a legend is nearer the plots than a title. A legend without entries takes no
881
+ lane.
882
+ * **`share_legend`** (`False`, `True`/`"all"`, `"row"`, `"col"`) makes figure legends for
883
+ the groups `share_color` would make (two plots or more): one on the right of the
884
+ figure (`"all"`), of each row (`"row"`), one at the bottom of each column (`"col"`).
885
+ A group with a plot an `add_legend` legend covers gets none. They take the
886
+ `FigureLegend` (and `Legend`) keys of the style, but their `side`.
887
+ * `p.save()` (one plot alone) leaves out figure legends: the plot's legend shows all its
888
+ entries.
889
+
890
+ Figure legends have the settings of plot legends but `position`, `orientation`, and:
891
+
892
+ <!-- settings:FigureLegend -->
893
+ | Setting | Default | Meaning |
894
+ |---|---|---|
895
+ | `side` | 'right' | `top`, `bottom`, `left` or `right` of its plots. |
896
+ | `align` | 'center' | Alignment along the side: `start` (left, or top), `center`, `end` (right, or bottom). |
897
+ | `order` | — | Place in its side's lanes, as figure titles' `order`: lower is nearer the plots. |
898
+ | `pad` | 5.0 | Gap between the legend and the plots. Length. |
899
+ | `title` | 'auto' | Legend title; `"auto"`: the `group` column name of its plots' series, if any. |
900
+ <!-- /settings -->
901
+
902
+ ### Decorations
903
+
904
+ Reference lines, bands, text and annotations. They take no palette color, are in the
905
+ legend only with a `name`, and change the limits only with `extend_limits=True`. They
906
+ are drawn among the series by `z`: spans under the series (`z=-1`), lines and text over
907
+ them (`z=1`).
908
+
909
+ ```python
910
+ p.hline(y, min="0%", max="100%", color="#4d4d4d", line_style="solid", ...) # min/max: data values or % of the axes
911
+ p.vline(x, ...)
912
+ p.axline((x0, y0), slope=None, point2=None, ...) # slope: linear axes only
913
+ p.hspan(y0, y1, color="#e5e5e5", ...); p.vspan(x0, x1, ...)
914
+ p.text(x, y, content, align="left", valign="baseline", rotation=0, coords="data", ...)
915
+ p.annotate(content, xy, xytext=None, text_coords=None, arrow_style="->", ...)
916
+ ```
917
+
918
+ Positions are data values (category names on category axes), or fractions with
919
+ `coords="axes"` or `"figure"`. `text_coords="offset"` gives `xytext` in points from `xy`
920
+ (y up). Text is a string or rich content. Arrows run from the edge of the text box to
921
+ `xy`, `shrink` points short of both.
922
+
923
+ HLine:
924
+
925
+ <!-- settings:HLine -->
926
+ | Setting | Default | Meaning |
927
+ |---|---|---|
928
+ | `color` | '#4d4d4d' | Line color. |
929
+ | `line_width` | inherited (0.5) | Line width. Length. |
930
+ | `line_style` | 'solid' | `solid`, `dashed`, `dotted`, `dashdot` or a dash list. Length. |
931
+ | `min` | '0%' | Start: a data value, or `%` (or a length) from the start of the axes. Length; `%`: of the axes length along the axis; bare numbers: data units. |
932
+ | `max` | '100%' | End: a data value, or `%` (or a length) from the start of the axes. Length; `%`: of the axes length along the axis; bare numbers: data units. |
933
+ | `name` | — | Legend entry; unset: not in the legend. |
934
+ | `alpha` | 1.0 | Opacity. |
935
+ | `z` | 1.0 | Drawing order among the series (default 0). |
936
+ | `extend_limits` | False | Include the decoration in the axis limits. |
937
+ | `clip` | True | Clip to the axes area. |
938
+
939
+ Groups: `Stroke`.
940
+ <!-- /settings -->
941
+
942
+ AxLine:
943
+
944
+ <!-- settings:AxLine -->
945
+ | Setting | Default | Meaning |
946
+ |---|---|---|
947
+ | `color` | '#4d4d4d' | Line color. |
948
+ | `line_width` | inherited (0.5) | Line width. Length. |
949
+ | `line_style` | 'solid' | `solid`, `dashed`, `dotted`, `dashdot` or a dash list. Length. |
950
+ | `name` | — | Legend entry; unset: not in the legend. |
951
+ | `alpha` | 1.0 | Opacity. |
952
+ | `z` | 1.0 | Drawing order among the series (default 0). |
953
+ | `extend_limits` | False | Include the decoration in the axis limits. |
954
+ | `clip` | True | Clip to the axes area. |
955
+
956
+ Groups: `Stroke`.
957
+ <!-- /settings -->
958
+
959
+ HSpan:
960
+
961
+ <!-- settings:HSpan -->
962
+ | Setting | Default | Meaning |
963
+ |---|---|---|
964
+ | `color` | '#e5e5e5' | Fill color. |
965
+ | `edge_color` | — | Outline color; default none. |
966
+ | `edge_width` | 0.0 | Outline width. Length. |
967
+ | `min` | '0%' | Start: a data value, or `%` (or a length) from the start of the axes. Length; `%`: of the axes length along the axis; bare numbers: data units. |
968
+ | `max` | '100%' | End: a data value, or `%` (or a length) from the start of the axes. Length; `%`: of the axes length along the axis; bare numbers: data units. |
969
+ | `name` | — | Legend entry; unset: not in the legend. |
970
+ | `alpha` | 1.0 | Opacity. |
971
+ | `z` | -1.0 | Drawing order among the series (default 0). |
972
+ | `extend_limits` | False | Include the decoration in the axis limits. |
973
+ | `clip` | True | Clip to the axes area. |
974
+
975
+ Groups: `Stroke` (`edge_`).
976
+ <!-- /settings -->
977
+
978
+ Text:
979
+
980
+ <!-- settings:Text -->
981
+ | Setting | Default | Meaning |
982
+ |---|---|---|
983
+ | `align` | 'left' | Horizontal alignment on the point. |
984
+ | `valign` | 'baseline' | Vertical alignment on the point. |
985
+ | `rotation` | 0.0 | Rotation (degrees, counterclockwise). Angle (bare: degrees). |
986
+ | `coords` | 'data' | `data`, `axes` (0–1) or `figure` (0–1). |
987
+ | `color` | 'var(text_color)' | Text color; default `text_color`. |
988
+ | `font_size` | inherited (11.0) | Font size. Length; `%`: of the parent's font size. |
989
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
990
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
991
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
992
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
993
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
994
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
995
+ | `font_weight` | 'normal' | `normal`, `bold` or a weight 1–1000. |
996
+ | `font_style` | 'normal' | `normal`, `italic`, `oblique` or `"oblique 10deg"`. |
997
+ | `text_color` | inherited ('black') | Text color. |
998
+ | `name` | — | Legend entry; unset: not in the legend. |
999
+ | `alpha` | 1.0 | Opacity. |
1000
+ | `z` | 1.0 | Drawing order among the series (default 0). |
1001
+ | `extend_limits` | False | Include the decoration in the axis limits. |
1002
+ | `clip` | False | Clip to the axes area. |
1003
+
1004
+ Groups: `TextStyle`, `Font`.
1005
+ <!-- /settings -->
1006
+
1007
+ Annotate:
1008
+
1009
+ <!-- settings:Annotate -->
1010
+ | Setting | Default | Meaning |
1011
+ |---|---|---|
1012
+ | `align` | 'center' | Horizontal alignment on `xytext`. |
1013
+ | `valign` | 'center' | Vertical alignment on `xytext`. |
1014
+ | `text_coords` | 'var(coords)' | Coordinates of `xytext`: as `coords`, or `offset` (px from `xy`, y up); default `coords`. |
1015
+ | `arrow` | True | Draw an arrow from the text to `xy`. |
1016
+ | `arrow_style` | '->' | `->` (open head), `-\|>` (filled head) or `-` (no head). |
1017
+ | `arrow_color` | 'var(color)' | Arrow color; default the text color. |
1018
+ | `arrow_width` | 0.5 | Arrow line width. Length. |
1019
+ | `head_length` | 7.0 | Arrowhead length. Length. |
1020
+ | `shrink` | 3.0 | Gap left at both ends of the arrow. Length. |
1021
+
1022
+ Groups: `Stroke` (`arrow_`).
1023
+ <!-- /settings -->
1024
+
1025
+ ## 4. Axes
1026
+
1027
+ ### Scales
1028
+
1029
+ | `scale` | Position | Domain |
1030
+ |---|---|---|
1031
+ | `linear` | v | all |
1032
+ | `log`, `log2`, `log10` | ln v, log₂ v, log₁₀ v | v > 0 |
1033
+ | `sqrt` | √v | v ≥ 0 |
1034
+ | `exp` | eᵛ | v < 709 |
1035
+ | `symlog` | sign(v)·log₁₀(1 + abs(v)/`linthresh`) | all |
1036
+ | `logit` | log₁₀(p/(1 − p)) | 0 < p < 1 |
1037
+ | `time` | seconds since 1970-01-01 UTC | dates and times |
1038
+ | `category` | category index | categories |
1039
+ | `genome` | position in bp (less the axis' `origin`) | the axis' `region` |
1040
+
1041
+ The genome scale is linear, its limits the axis' `region` without padding, its tick labels
1042
+ in `unit` (bp, kb or Mb; `unit_in` puts the unit in the label or after each tick label),
1043
+ its automatic label the chromosome; genome series set it on an x axis without a scale
1044
+ ([§9](#9-genome-tracks)).
1045
+
1046
+ Values outside the domain are missing on that axis. The three logs place data
1047
+ identically; they differ in their ticks. Box and heatmap series with labels make their
1048
+ axis a category axis; mixing category and numeric series on one axis raises `ValueError`.
1049
+ `symlog` ticks: 0, ±`linthresh`, then decades. Inside the linear region (`linthresh`,
1050
+ default 1), minor ticks sit at the finest step of `linthresh`/10, /5, /4 or /2 that keeps
1051
+ them as far apart as minor ticks 4 and 5 of a log decade, or are left out. `logit` ticks: 0.5, then 0.1/0.9, 0.01/0.99, …
1052
+
1053
+ ### Dates and times
1054
+
1055
+ `datetime`, `date`, numpy `datetime64` arrays and pandas timestamps given as x or y make a
1056
+ `time` axis (also bar positions; bar `width` takes a `timedelta`). Values become seconds
1057
+ since the epoch (naive ones read as UTC); aware ones are shown in their zone (`tz`, default
1058
+ the zone of the first value). Ticks follow the calendar: years (1, 2, 5, 10, …), months
1059
+ (1, 2, 3, 6), days (1, 2, 7, 14), hours (1, 2, 3, 6, 12), minutes, seconds and fractions,
1060
+ chosen from the span and `max_ticks`. Labels are concise (`2026`, `Mar`, `Mar 14`,
1061
+ `14:30`, `14:30:15`, `15.250`), with January labelled by its year, and the larger unit
1062
+ common to every tick written at the end of the axis, as the ×10ᵏ factor is
1063
+ (`2026`, `Mar 14, 2026`).
1064
+ `tick_format` takes a `strftime` pattern (`"%Y-%m"`) or a function of a `datetime`.
1065
+ `limits` take dates and ISO strings (`("2026-01-01", None)`, `"2026-01-01/max"`).
1066
+
1067
+ ### Secondary axes
1068
+
1069
+ ```python
1070
+ p2 = p.twin_y() # its own y axis on the right, p's x axis
1071
+ p2.line(t, temperature)
1072
+ p2.y_axis(label="Temperature (°C)", scale="log10")
1073
+ ```
1074
+
1075
+ `twin_y()` returns a plot drawn on `p`'s axes rectangle, sharing its x axis (limits from
1076
+ the series of both) with its own y axis on the right; `twin_x()` does the same for x (on
1077
+ top). The twin's axis adds margin on its side, and outside legends and colorbars move
1078
+ beyond it. Its series continue `p`'s palette and appear in `p`'s legend unless the twin's
1079
+ legend position is set. Background, title, frame and grid belong to `p` (a twin draws a
1080
+ grid only when its axis asks). `p.save` includes its twins.
1081
+
1082
+ ### Limits
1083
+
1084
+ * `"auto"`: the union of the series' extents plus `padding` (0.05 of the range per side,
1085
+ in position space: a factor on log axes; heatmaps take none).
1086
+ * `"lo/hi"`: each side `min`, `max`, a number or `q:F` (quantile F of the axis's values):
1087
+ `"0/max"`, `"q:0.01/q:0.99"`. Or `(lo, hi)`, `None` meaning automatic.
1088
+ * A single value is widened by ±0.5 in position space. `invert=True` reverses the axis.
1089
+ * `include_zero=True` extends automatic limits to 0 (linear and sqrt axes) before padding
1090
+ and `snap`; `"auto"` does so where a series on the axis asks for it, following
1091
+ Vega-Lite's default: both axes of scatter plots, the value axis of lines, areas and
1092
+ boxes, never category axes or heatmaps.
1093
+ * `snap` moves automatic limits (after padding) onto major ticks, on linear and log
1094
+ axes; given limits stay. The default `("4%", "8%")` (`(back, out)`, `%` of the axis
1095
+ length or px) extends a limit out to the next tick when it is within 8% of the axis,
1096
+ or pulls it back to a tick it passed by at most 4% when that tick is still outside the
1097
+ data; other limits stay as padded. `True` always extends to the enclosing ticks, as
1098
+ MATLAB and Vega-Lite do; `False` leaves the padded limits.
1099
+
1100
+ ### Ticks
1101
+
1102
+ * **linear:** steps 1, 2, 2.5 or 5 × 10ᵏ, at most `max_ticks` (default: axis length ÷
1103
+ 3.5 font sizes on x, 2.5 on y, at most 10); on x the step grows until labels do not
1104
+ overlap.
1105
+ * **log10:** decades labelled 10ᵏ, thinned to `max_ticks`, minor ticks 2–9. Below three
1106
+ decades, 1, 2 and 5 × 10ᵏ, labelled as numbers.
1107
+ * **log2:** powers of two, labelled as numbers from 2⁻¹⁰ to 2¹⁰, else 2ᵏ; thinned to every
1108
+ 2nd, 4th, … power. **log:** powers of e labelled eᵏ.
1109
+ * **sqrt, exp:** round values thinned so that neighbours are a tick spacing apart on the
1110
+ page, walking from the end the scale stretches.
1111
+ * **category:** one tick per category; labels turn 45° when they overlap
1112
+ (`tick_rotation="auto"`), and every k-th is kept when even that does not fit.
1113
+ * Labels of an axis share the fewest decimals that tell them apart. Beyond
1114
+ 10^`sci_limits` they are mantissas, and ×10ᵏ is written at the end of the axis:
1115
+ above the top of a y axis, at the right end of an x axis (on the title's row).
1116
+ * `ticks=[…]`, `tick_labels=[…]`, `minor_ticks=True|[…]`, `ticks=False`.
1117
+ * `tick_format` takes any [number format](#number-formats); the default `"auto"` is the
1118
+ rule above.
1119
+
1120
+ * **Grid lines:** `grid` at the major ticks, `minor_grid` at the minor ticks (or halfway
1121
+ between major ticks on linear axes without minor ticks), and `zero_line` at 0 (when 0
1122
+ is within the limits), under the series.
1123
+ * **Sides:** `side="top"` (x) or `"right"` (y) moves the ticks, labels and axis line
1124
+ (`spines` is mirrored with them).
1125
+ * **Axis lines:** `mirror` repeats the ticks on the opposite side; `spine_offset` moves
1126
+ the axis line, its ticks and labels away from the axes; `spine_trim` draws the line from
1127
+ the first to the last major tick. `color` sets the default of `line_color`,
1128
+ `tick_color`, `tick_label_color` and `label_color`.
1129
+
1130
+ <!-- settings:Axis -->
1131
+ | Setting | Default | Meaning |
1132
+ |---|---|---|
1133
+ | `label` | — | Axis title: a string or rich content; `\n` starts a line in a row band. |
1134
+ | `label_position` | 'axis' | Where the label of a plot's y axis goes: `axis` (beside the tick labels); in a band left of the plot, lined up with the labels of the other plots of its grid column (row labels): `band` (rotated) or `left` (horizontal, right-aligned); `inside` (top left inside the axes). |
1135
+ | `label_font_size` | '1em' | Font size of the label; default: the base font size. Length; `%`: of the font size. |
1136
+ | `label_weight` | 'normal' | Axis title weight: `normal`, `bold` or 1–1000. |
1137
+ | `label_style` | 'normal' | Axis title style: `normal`, `italic`, `oblique` or `"oblique 10deg"`. |
1138
+ | `label_color` | 'var(color)' | Axis title color. |
1139
+ | `scale` | — | `linear`, `log`, `log2`, `log10`, `sqrt`, `exp`, `symlog`, `logit`, `time`, `category` or `genome`; default: `category` for categorical series, `time` for dates, `genome` for genome series, else `linear`. |
1140
+ | `region` | — | Genome scale: the region drawn, its limits: `"chr2:143,120,001-143,780,000"` (1-based, inclusive), `(chr, start, end)` (0-based, half-open) or a mapping; genome series read it. |
1141
+ | `unit` | 'auto' | Genome scale: unit of the tick labels; `auto`: with ticks about a fifth of the span apart, the largest unit in which they are at least 1 apart and at most 1000, else the largest in which they are at most 1000 with at most 3 decimals, else bp. |
1142
+ | `unit_in` | 'label' | Genome scale: where the unit is written, in the axis label (`chr2 (Mb)`) or after each tick label (`500kb`). |
1143
+ | `origin` | — | The value drawn at 0 for the axis' series (a series' own `x_origin` wins): a number, or `"center"`, `"start"`, `"end"` of the region (genome scale), else of each series' range. Values are drawn at `(v − origin) × x_scale`; limits, ticks and decorations are in the drawn units. |
1144
+ | `linthresh` | 1.0 | Half-width of the linear region of a `symlog` axis. |
1145
+ | `tz` | — | Time zone of a time axis (a `tzinfo`); default: the zone of the first aware date, else naive (UTC). |
1146
+ | `limits` | 'auto' | `"auto"`, `"lo/hi"` or `[lo, hi]` (a tuple too); each side a number, `"min"`, `"max"`, `"q:F"` (a quantile), a date, or `"auto"`/`None`: `"0/max"` is `[0, "max"]`. |
1147
+ | `padding` | 'auto' | Space added to automatic limits, as a fraction of the range; `"auto"`: `auto_padding`, or 0 on axes of series drawn to exact limits (box value axes, heatmaps, …) and in plots without axes. Length; `%`: of the axis range. |
1148
+ | `auto_padding` | '5%' | The fraction `padding="auto"` adds on each side. Length; `%`: of the axis range. |
1149
+ | `sticky` | True | No padding past the baseline of bars and histograms when an automatic limit is on it (matplotlib's sticky edges). |
1150
+ | `invert` | False | Reverse the axis. |
1151
+ | `ticks` | — | `False` (no ticks) or a list of tick values. |
1152
+ | `tick_labels` | — | Labels of `ticks`. |
1153
+ | `minor_ticks` | — | `True`, `False` or a list of values; default: on for log10. |
1154
+ | `tick_format` | 'auto' | Number format: `auto`, `percent`, `sci`, `eng`, `si`, `int`, a format string or a function; on a genome axis also `chr:pos` (`chr2:143,250,000`). |
1155
+ | `tick_rotation` | 'auto' | Label rotation in degrees, or `"auto"` (45° when category labels overlap). Angle (bare: degrees). |
1156
+ | `max_ticks` | 'auto' | Most major ticks; `"auto"`: one per `tick_spacing` of axis length, at least 2, at most `auto_max_ticks`. |
1157
+ | `tick_spacing` | ('3em', '2em') | Space per automatic tick, in tick label font sizes, on horizontal and vertical axes. Length; `em` and `%`: of `tick_label_font_size`. |
1158
+ | `time_tick_spacing` | ('5em', '2.5em') | `tick_spacing` of time axes. Length; `em` and `%`: of `tick_label_font_size`. |
1159
+ | `tick_label_gap` | '0.6em' | Smallest gap between neighbouring tick labels side by side: fewer numeric ticks, or category labels rotated and thinned out, below it. Length; `em` and `%`: of `tick_label_font_size`. |
1160
+ | `category_label_spacing` | ('1.6em', '1.3em') | Distance between category labels: rotated (horizontal axes) and stacked (vertical axes); labels closer than it are thinned out. Length; `em` and `%`: of `tick_label_font_size`. |
1161
+ | `auto_max_ticks` | (10, 8) | Most automatic ticks on numeric and time axes. |
1162
+ | `sci_limits` | (-4, 5) | Exponents beyond which labels become mantissas × 10ᵏ. |
1163
+ | `tick_length` | 6.0 | Tick length. Length; `%`: of the axes side across the axis. |
1164
+ | `minor_tick_length` | '60%' | Minor tick length; default 0.6 × `tick_length`. Length; `%`: of `tick_length`. |
1165
+ | `tick_direction` | 'out' | `out`, `in` or `both`. |
1166
+ | `tick_color` | 'var(color)' | Tick color. |
1167
+ | `tick_width` | 0.5 | Tick line width. Length. |
1168
+ | `tick_label_font_size` | '1em' | Font size of tick labels. Length; `%`: of the font size. |
1169
+ | `tick_label_weight` | 'normal' | Tick label weight: `normal`, `bold` or 1–1000. |
1170
+ | `tick_label_color` | 'var(color)' | Tick label color. |
1171
+ | `tick_pad` | 5.0 | Gap between ticks and labels. Length; `%`: of the axes side across the axis. |
1172
+ | `label_pad` | 5.0 | Gap between tick labels and the label. Length; `%`: of the axes side across the axis. |
1173
+ | `color` | 'var(text_color)' | Color of the axis line, ticks and labels (the default of `line_color`, `tick_color`, `tick_label_color`, `label_color`). |
1174
+ | `line_color` | 'var(color)' | Axis line color. |
1175
+ | `line_width` | 0.5 | Axis line width. Length. |
1176
+ | `side` | x: 'bottom' / y: 'left' | Where the ticks, labels and axis line go: `bottom` or `top` (x axis), `left` or `right` (y axis). |
1177
+ | `mirror` | False | Ticks also on the opposite side of the axes. |
1178
+ | `spine_offset` | 0.0 | Distance the axis line (with its ticks and labels) is moved away from the axes. Length; `%`: of the axes side across the axis. |
1179
+ | `spine_trim` | False | Axis line from the first to the last major tick only. |
1180
+ | `include_zero` | False | Extend automatic limits to 0 (linear and sqrt scales), before padding and `snap`: `True`, or `"auto"` where a series on the axis asks for it (Vega-Lite's rule: scatter axes, the value axis of lines, areas and boxes). |
1181
+ | `zero_line` | False | A line across the plot at 0. |
1182
+ | `zero_line_color` | 'var(line_color)' | Zero line color; default `line_color`. |
1183
+ | `zero_line_width` | 'var(line_width)' | Zero line width; default `line_width`. Length. |
1184
+ | `snap` | ('4%', '8%') | Automatic limits on major ticks (linear and log scales): `True`, out to the enclosing ticks; `(back, out)`, out to a tick within `out` (`%` of the axis), or back to one within `back` that is still outside the data; `False`: as padded. Length; `%`: of the axis range. |
1185
+ | `grid` | False | Major grid lines across the plot. |
1186
+ | `grid_color` | '#dddddd' | Grid line color. |
1187
+ | `grid_width` | 0.5 | Grid line width. Length. |
1188
+ | `grid_style` | 'solid' | Grid line style or dash list. Length. |
1189
+ | `minor_grid` | False | Minor grid lines: at the minor ticks, or halfway between major ticks on linear axes without minor ticks. |
1190
+ | `minor_grid_color` | 'var(grid_color)' | Minor grid color; default `grid_color`. |
1191
+ | `minor_grid_width` | '50%' | Minor grid width; default half `grid_width`. Length; `%`: of `grid_width`. |
1192
+ | `minor_grid_style` | 'var(grid_style)' | Minor grid style; default `grid_style`. Length. |
1193
+ | `visible` | True | Draw the axis (ticks, labels). |
1194
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1195
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1196
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1197
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1198
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1199
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1200
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1201
+ | `text_color` | inherited ('black') | Text color. |
1202
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
1203
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
1204
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
1205
+ | `prefix` | inherited ('') | Text before every number. |
1206
+ | `suffix` | inherited ('') | Text after every number. |
1207
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
1208
+
1209
+ Groups: `TextStyle` (`label_`), `Stroke` (`tick_`), `TextStyle` (`tick_label_`), `Stroke` (`line_`), `Stroke` (`zero_line_`), `Stroke` (`grid_`), `Stroke` (`minor_grid_`), `Font`, `NumberFormat`.
1210
+ <!-- /settings -->
1211
+
1212
+ ## 5. Series
1213
+
1214
+ All series take `name`, `alpha`, `z`, `rasterize` and `simplify` (see [Output](#8-output)).
1215
+ Series without their own color take the plot's next palette color, in call order; series
1216
+ with several value sets (histograms, densities, areas, pies) take one per set.
1217
+
1218
+ * **Layers.** A series is a preset of layers: each a stat (columns computed from the
1219
+ data: bins, densities, quartiles, fits, contours…), a position (stack, dodge, jitter,
1220
+ swarm, rows of intervals), and one of eight geoms that draws the columns (points,
1221
+ paths, bands, rectangles, polygons, segments, cells, text). A box plot is rectangles,
1222
+ segments and points from one box stat; it has one legend entry. Positions run once per
1223
+ plot over all its series, before the axes are fitted.
1224
+ * **Orientation.** Every series with x and y data takes `orientation="horizontal"`
1225
+ (scatter, line, fill, area, bar, hist, kde, ecdf, box, violin, strip, swarm, errorbar,
1226
+ stem, regression): its x data go along the y axis, its y data along the x axis, and it
1227
+ draws the same marks with x and y swapped (curves along y, steps included). Grids
1228
+ (heatmap, hist2d, hexbin, contour, 2-D kde) and pies have none: swap their arguments.
1229
+ * **New types.** `pl.register_layer(name, factory)` adds `plot.<name>(…)`, which calls
1230
+ `factory(…, plot=plot)`. A factory that is a `pl.Series` subclass implements
1231
+ `layers()`, returning its `Call` (layers, legend entries, what the axes, maps and
1232
+ palette need; see `plot_io/layers/`); its class name is a style class. The genome types
1233
+ are registered so (`plot.bigwig(…)`, …).
1234
+
1235
+ * **Category slots.** Box and violin series, bar series, and strip and swarm series form
1236
+ three dodge groups: the series of a group that have a category split its slot (`width`)
1237
+ side by side, in call order; `dodge=False` overlays a series; `gap` leaves part of each
1238
+ share empty (`"10%"`). `width` is a `%` of the slot (one category, or the smallest gap
1239
+ between numeric `positions`), a length (px), or data units (`"0.8d"`). Stacked bars
1240
+ count as one, and so do split violins.
1241
+ * **Stacking.** `stack=True` (bars, histograms, densities) puts a series on the previous
1242
+ stacked series of its kind in the plot, per category or bin; positive and negative
1243
+ values stack apart; `stack="normalize"` divides each position by its total.
1244
+ * **Derived data.** Histograms, densities, ECDFs, violins, 2-D bins, contours and
1245
+ regressions compute their data once (in C, by plot_io's kernels) and keep it until
1246
+ a setting changes; `series.stats` exposes it.
1247
+ * **Shifted and rescaled coordinates.** `x_origin`, `x_scale` and `x_extent` (and `y_…`)
1248
+ draw a series' values `v` at `(v − origin) × scale`, without changing the data:
1249
+ `p.line(profile, x_origin="center")` draws positions 0…1000 at −500…500, `x_scale=10`
1250
+ makes bins of 10 (−5000…5000), and `x_extent="-5000/5000"` maps the series' smallest x
1251
+ to −5000 and its largest to 5000 (replacing origin and scale). `"center"` is the middle
1252
+ of the series' range, `"start"`/`"end"` its smallest/largest value. Limits, ticks and
1253
+ decorations (`p.vline(0)`) are in the drawn units. An axis' `origin`
1254
+ (`p.x_axis(origin="center")`, `fig.x_axis(…)` for every plot) applies to every series on
1255
+ it that has no `x_origin` of its own (on a genome axis, `"center"` is the middle of its
1256
+ region). Category axes ignore them, and they need a linear, time or genome axis.
1257
+
1258
+ <!-- settings:Transforms -->
1259
+ | Setting | Default | Meaning |
1260
+ |---|---|---|
1261
+ | `x_origin` | — | The x value drawn at 0: a number, `"center"` (the middle of the series' x range), `"start"` or `"end"` (its smallest or largest x); unset: the x axis' `origin`. Values are drawn at `(x − x_origin) × x_scale`. |
1262
+ | `x_scale` | 1.0 | Factor on x values after `x_origin` (e.g. bp per bin); default 1. |
1263
+ | `x_extent` | — | The span the series' x range is drawn over, `"lo/hi"` or `[lo, hi]`: its smallest x at `lo`, its largest at `hi`; replaces `x_origin` and `x_scale`. |
1264
+ | `y_origin` | — | The y value drawn at 0: a number, `"center"` (the middle of the series' y range), `"start"` or `"end"` (its smallest or largest y); unset: the y axis' `origin`. Values are drawn at `(y − y_origin) × y_scale`. |
1265
+ | `y_scale` | 1.0 | Factor on y values after `y_origin` (e.g. bp per bin); default 1. |
1266
+ | `y_extent` | — | The span the series' y range is drawn over, `"lo/hi"` or `[lo, hi]`: its smallest y at `lo`, its largest at `hi`; replaces `y_origin` and `y_scale`. |
1267
+ <!-- /settings -->
1268
+
1269
+ ### Tables (`data=`)
1270
+
1271
+ ```python
1272
+ p.scatter("umap_x", "umap_y", data=genes, c="density", group="cluster")
1273
+ pl.Box("expression", data=df, x="tissue", group="sex")
1274
+ p = pl.Plot(data=df); p.scatter("a", "b") # data inherited by the plot's series
1275
+ ```
1276
+
1277
+ `data` is any object returning a column for `data[name]`: a dict of sequences, a pandas
1278
+ or polars data frame, a numpy structured array. Columns are read through `__getitem__`
1279
+ (and `to_numpy()` when present); no table library is imported. With `data`, a string in
1280
+ a positional data argument or in `color`, `edge_color`, `size`, `alpha`, `group`,
1281
+ `draw_order`, `x_error`, `y_error`, `weights`, `positions`, `x`, `y` or `names` names a
1282
+ column. Positional arguments, `group`, `weights` and `positions` must be columns; in
1283
+ `color`, a color name that is no column stays a color (a column wins, with a warning if
1284
+ the name is also a color). Axis titles default to the column names drawn on the axes,
1285
+ the colorbar label to the `color` column, the legend title to the `group` column.
1286
+ `data` is also a plot and figure setting, inherited by their series. Pandas categorical
1287
+ columns keep their category order for groups and category axes.
1288
+
1289
+ Box, violin, strip and swarm also take long data: `values` flat, with the category of each
1290
+ value in `x` (`y` when horizontal).
1291
+
1292
+ ### Groups (`group=`)
1293
+
1294
+ ```python
1295
+ g = p.scatter(x, y, group=labels, marker="auto") # one series per group
1296
+ g = p.line(t, y, group=subject, line_style="auto")
1297
+ g["a"].set(color="black"); g.set(alpha=0.6)
1298
+ ```
1299
+
1300
+ `group` takes a label per point. The call returns a `SeriesGroup`, a list of one series per
1301
+ group (first-appearance order, the categorical order of a pandas column, or
1302
+ `group_order=[…]`), each with the rows of every per-point argument that belong to it,
1303
+ the group label as `name` and the next palette color (`group_colors={label: color}` sets
1304
+ some). `marker="auto"` cycles marker shapes and `line_style="auto"` line styles over the
1305
+ groups. Missing labels (`None`, NaN) form a `"nan"` group, or are dropped with
1306
+ `group_missing="drop"`. `set()` on the group applies to every member; `group[label]` (or
1307
+ an index) is one member; `labels` lists them. For box, violin, bar, strip and swarm the
1308
+ groups are dodged within each category slot. Densities (`"density"`) are computed per
1309
+ member, and `draw_order` sorts within each member.
1310
+
1311
+ ### Scatter
1312
+
1313
+ ```python
1314
+ pl.Scatter(x, y, plot=None, **settings)
1315
+ ```
1316
+
1317
+ `color`, `edge_color`, `size`, `marker` take one value or one per point. Numbers per
1318
+ point in `color` and `edge_color` are mapped through `color_map` (alias `cmap`; default:
1319
+ the style's map); numbers in `size` are diameters, or values mapped through `size_map`
1320
+ (alias `smap`) when it is set. See [values](#values-in-color-and-size).
1321
+
1322
+ * `size` is a diameter (a length; per-point numbers are px). With `size_basis="area"` (default) every shape has the
1323
+ area of the circle of that diameter: a square of size 4 is drawn 3.54 px wide.
1324
+ * Error bars: `x_error`/`y_error` take a value, a sequence, `(low, high)` sequences or
1325
+ `ErrorBars(values, color=None, line_width=None, cap_length=None)` (cap: the series'
1326
+ `cap_length`, else 4 px).
1327
+
1328
+ <!-- settings:Scatter -->
1329
+ | Setting | Default | Meaning |
1330
+ |---|---|---|
1331
+ | `marker` | 'circle' | Marker name, `Path` or path data, or one per point. |
1332
+ | `size` | 4.5 | Marker size: the diameter of the circle of equal area; one value or one per point; numbers per point are values to map when `size_map` is set; or `"density"`. Length. |
1333
+ | `color` | — | Fill: a color, colors per point, numbers per point (mapped through `color_map`) or `"density"`. |
1334
+ | `edge_color` | 'auto' | Outline: as the fill color, or `"auto"` (white around filled markers; hollow ones outlined in their color). |
1335
+ | `edge_width` | 0.5 | Outline width; 0: no outline. Length. |
1336
+ | `fill` | True | `True`: filled with the color; `False`: hollow, outlined in the color; an opacity (0–1): filled at that opacity and outlined in the color. |
1337
+ | `size_basis` | 'area' | `area`: shapes of the same size have the same area; `box`: size is the width of the shape's box. |
1338
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1339
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1340
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1341
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1342
+ | `size_map` | — | The sizes numbers in `size` are drawn with: a `SizeMap` (alias `smap`); without it (or `size_axis`), numbers are sizes in px. |
1343
+ | `size_limits` | — | Limits of the series' size axis, as an axis' `limits`; unset: `"auto"`. |
1344
+ | `size_scale` | — | Scale of the series' size axis; unset: `linear`. |
1345
+ | `size_axis` | — | A shared `SizeAxis` (`figure.size_axis(…)`) in place of the series' own: it holds the sizes, limits and scale. |
1346
+ | `size_legend` | True | With mapped sizes: a size key in the legend (`True`), none (`False`), or the values to show (a list). |
1347
+ | `draw_order` | — | Drawing order: `"density"` (densest drawn last), `"-density"`, or sort keys per point (ascending); default: call order. |
1348
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own; or `"density"` / a `Density`, mapped linearly to `alpha_range`. |
1349
+ | `alpha_range` | (0.2, 1.0) | Opacities of the least and most dense points when `alpha` is a density. |
1350
+ | `x_error` | — | Horizontal error bars: a value, a sequence, `(low, high)` or `ErrorBars`. |
1351
+ | `y_error` | — | Vertical error bars. |
1352
+ | `orientation` | 'vertical' | `vertical` (x along the x axis) or `horizontal` (x along the y axis). |
1353
+ | `name` | — | Legend entry; unset: not in the legend. |
1354
+ | `z` | — | Drawing order (higher on top); default: call order. |
1355
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1356
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1357
+ | `text_color` | inherited ('black') | Text color. |
1358
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1359
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1360
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1361
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1362
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1363
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1364
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1365
+
1366
+ Groups: `Marker`, `Font`.
1367
+ <!-- /settings -->
1368
+
1369
+ ### Line
1370
+
1371
+ ```python
1372
+ pl.Line(x, y=None, plot=None, **settings) # y 2-D: one line per row; x omitted: 0, 1, 2, …
1373
+ ```
1374
+
1375
+ Named line styles scale with the width. Markers (`marker`, `marker_size`,
1376
+ `marker_color`, …) are drawn at the points when `marker` or `show_markers` is set.
1377
+ Numbers per point (or `"density"`, of a single line) in `marker_color` and
1378
+ `marker_edge_color` go through the series' [color axis](#6-color-and-size-axes)
1379
+ (`color_map`, `color_limits`, `color_scale`, `color_axis`; `p.colorbar(line)`), as
1380
+ `color` does on Scatter; the line keeps `color`, and the legend's marker takes the
1381
+ gradient's middle color.
1382
+
1383
+ * `interpolation`: `linear`; `step-pre`, `step-post`, `step-mid`; `monotone` (a cubic
1384
+ through every point that never overshoots, Fritsch–Carlson; `spline` where x is not
1385
+ monotonic); `spline` (centripetal Catmull–Rom, may overshoot). Each segment is one exact
1386
+ Bézier, computed on the page after the axis scales, by vec_io in C. Steps and curves
1387
+ are not decimated by `simplify`.
1388
+ * `missing`: `break` (default) ends a run at a missing value (NaN, `None`, or outside the
1389
+ axis scale's domain); runs are drawn on their own and a one-point run draws nothing.
1390
+ `skip` connects the points on either side.
1391
+
1392
+ <!-- settings:Line -->
1393
+ | Setting | Default | Meaning |
1394
+ |---|---|---|
1395
+ | `color` | — | Line color; default: the next palette color. |
1396
+ | `line_width` | inherited (0.5) | Line width. Length. |
1397
+ | `line_style` | 'solid' | `solid`, `dashed`, `dotted`, `dashdot` or a dash list; named styles scale with the width. Length. |
1398
+ | `cap` | 'butt' | Line cap. |
1399
+ | `join` | 'round' | Line join. |
1400
+ | `interpolation` | 'linear' | How points are joined: `linear`, `step-pre`, `step-post`, `step-mid`, `monotone` (a curve that never overshoots) or `spline` (centripetal Catmull–Rom). |
1401
+ | `missing` | 'break' | Missing values: `break` the line there, or `skip` them and connect their neighbours. |
1402
+ | `marker` | 'circle' | Marker name, `Path` or path data, or one per point. |
1403
+ | `marker_size` | 4.5 | Marker size: the diameter of the circle of equal area, in px; one value or one per point. Length. |
1404
+ | `marker_color` | — | Fill: a color, colors per point, numbers per point (mapped through `color_map`) or `"density"`. |
1405
+ | `marker_edge_color` | 'auto' | Outline: as the fill color, or `"auto"` (white around filled markers; hollow ones outlined in their color). |
1406
+ | `marker_edge_width` | 0.5 | Outline width; 0: no outline. Length. |
1407
+ | `marker_fill` | True | `True`: filled with the color; `False`: hollow, outlined in the color; an opacity (0–1): filled at that opacity and outlined in the color. |
1408
+ | `size_basis` | 'area' | `area`: shapes of the same size have the same area; `box`: size is the width of the shape's box. |
1409
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1410
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1411
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1412
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1413
+ | `x_error` | — | Horizontal error bars at the points. |
1414
+ | `y_error` | — | Vertical error bars at the points. |
1415
+ | `show_markers` | False | Draw markers at the points (also turned on by setting `marker`). |
1416
+ | `orientation` | 'vertical' | `vertical` (x along the x axis) or `horizontal` (x along the y axis). |
1417
+ | `name` | — | Legend entry; unset: not in the legend. |
1418
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
1419
+ | `z` | — | Drawing order (higher on top); default: call order. |
1420
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1421
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1422
+ | `text_color` | inherited ('black') | Text color. |
1423
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1424
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1425
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1426
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1427
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1428
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1429
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1430
+
1431
+ Groups: `Stroke`, `Marker` (`marker_`), `Font`.
1432
+ <!-- /settings -->
1433
+
1434
+ ### Fill
1435
+
1436
+ ```python
1437
+ pl.Fill(x, y1, y2=0, plot=None, **settings) # y1 may be two rows [upper, lower]
1438
+ ```
1439
+
1440
+ `interpolation` and `missing` work as for lines, on both edges (a point is missing when
1441
+ x, y1 or y2 is), so a band with the settings of its line matches it, horizontal ones
1442
+ included (`fill(y, x1, x2, orientation="horizontal")`: the curves run along y).
1443
+ `color_below` colors the parts where `y1` is below `y2` (a difference between two curves,
1444
+ each side in its color).
1445
+
1446
+ <!-- settings:Fill -->
1447
+ | Setting | Default | Meaning |
1448
+ |---|---|---|
1449
+ | `color` | — | Fill color; default: the next palette color. |
1450
+ | `color_below` | — | Fill color where `y1` is below `y2` (crossings found on straight segments); default `color` everywhere. |
1451
+ | `alpha` | 'calc(0.3 * inherit)' | Opacity; default 0.3 × the plot's. |
1452
+ | `edge_color` | — | Outline color; default none. |
1453
+ | `edge_width` | 'var(line_width)' | Outline width; default the line width. Length. |
1454
+ | `interpolation` | 'linear' | How points are joined: `linear`, `step-pre`, `step-post`, `step-mid`, `monotone` (a curve that never overshoots) or `spline` (centripetal Catmull–Rom). |
1455
+ | `missing` | 'break' | Missing values: `break` the line there, or `skip` them and connect their neighbours. |
1456
+ | `orientation` | 'vertical' | `vertical`: between y curves; `horizontal`: between x curves. |
1457
+ | `name` | — | Legend entry; unset: not in the legend. |
1458
+ | `z` | — | Drawing order (higher on top); default: call order. |
1459
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1460
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1461
+ | `text_color` | inherited ('black') | Text color. |
1462
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1463
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1464
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1465
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1466
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1467
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1468
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1469
+
1470
+ Groups: `Stroke` (`edge_`), `Font`.
1471
+ <!-- /settings -->
1472
+
1473
+ ### Box
1474
+
1475
+ ```python
1476
+ pl.Box(values, positions=None, plot=None, **settings)
1477
+ box.stats # {category: BoxStats(count, mean, q1, median, q3, low, high, outliers)}
1478
+ ```
1479
+
1480
+ `values`: a dict `{category: values}`, a list of arrays (categories `0, 1, …` or
1481
+ `categories=`), or one array. `positions` places the boxes on a numeric axis instead.
1482
+ Quartiles interpolate linearly (numpy's default); whiskers reach the furthest data within
1483
+ `whiskers` × IQR, or the range, or percentiles; points beyond are outliers. Box series of
1484
+ a plot share each category's slot side by side, in call order, among those having that
1485
+ category.
1486
+
1487
+ <!-- settings:Box -->
1488
+ | Setting | Default | Meaning |
1489
+ |---|---|---|
1490
+ | `color` | — | Box fill: a color, one per box (list or dict by category), or numbers per box (list or dict) mapped through `color_map`; default: the next palette color. |
1491
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1492
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1493
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1494
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1495
+ | `edge_color` | 'series' | Box outline, whiskers, caps and median: a color, `"series"` (each box's own color) or `"auto"` (a grey 0.6 × as light as the series' lightest color, as seaborn). |
1496
+ | `edge_width` | 0.5 | Outline width. Length. |
1497
+ | `whisker_color` | — | Whisker and cap color; default `edge_color`. |
1498
+ | `whisker_width` | 'var(edge_width)' | Whisker and cap width; default `edge_width`. Length. |
1499
+ | `whisker_style` | 'solid' | Whisker line style: `solid`, `dashed`, `dotted`, `dashdot` or a dash list (caps stay solid). Length. |
1500
+ | `median_color` | — | Median line color; default `edge_color`. |
1501
+ | `median_width` | 'calc(3 * var(edge_width))' | Median line width. Length. |
1502
+ | `max_width` | '60%' | Largest width of the series' part of a slot (as `width`); default none. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1503
+ | `width` | '80%' | Box width: `%` of the slot, a length (bare numbers: px), `d` data units, or a duration on time axes. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1504
+ | `cap_length` | '50%' | Whisker cap width (`%` of the box width). Length; `%`: of the box width. |
1505
+ | `whiskers` | 1.5 | Whisker reach: a multiple of the IQR, `"range"`, or percentiles `(lo, hi)`. |
1506
+ | `outliers` | True | Draw points beyond the whiskers. |
1507
+ | `saturation` | 1.0 | Saturation of the box fills (1: the colors as given; seaborn uses 0.75). |
1508
+ | `fill` | 0.25 | Box fill: an opacity of the box color, times `alpha` (lines keep `alpha`); `True` (opaque), a color, or `False`. |
1509
+ | `mean` | False | Draw the mean as a marker. |
1510
+ | `mean_marker` | 'diamond' | Marker of the mean. |
1511
+ | `mean_color` | 'white' | Fill of the mean marker (outline: `edge_color`). |
1512
+ | `orientation` | 'vertical' | `vertical` (categories on x) or `horizontal`. |
1513
+ | `dodge` | True | Box and violin series sharing a category share its slot side by side; `False` overlays them. |
1514
+ | `gap` | '10%' | Fraction of each box's part of a shared slot left empty. Length; `%`: of each series' part of a shared slot. |
1515
+ | `categories` | — | Category names of a list of arrays. |
1516
+ | `marker` | 'circle' | Marker name, `Path` or path data, or one per point. |
1517
+ | `marker_size` | 3.5 | Marker size: the diameter of the circle of equal area, in px; one value or one per point. Length. |
1518
+ | `marker_color` | — | Outlier fill: a color, or colors per outlier. |
1519
+ | `marker_edge_color` | — | Outlier outline: as the fill, or `"auto"` (white around filled markers; hollow ones outlined in their color). |
1520
+ | `marker_edge_width` | 0.5 | Outline width; 0: no outline. Length. |
1521
+ | `marker_fill` | True | `True`: filled with the color; `False`: hollow, outlined in the color; an opacity (0–1): filled at that opacity and outlined in the color. |
1522
+ | `size_basis` | 'area' | `area`: shapes of the same size have the same area; `box`: size is the width of the shape's box. |
1523
+ | `name` | — | Legend entry; unset: not in the legend. |
1524
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
1525
+ | `z` | — | Drawing order (higher on top); default: call order. |
1526
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1527
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1528
+ | `text_color` | inherited ('black') | Text color. |
1529
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1530
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1531
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1532
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1533
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1534
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1535
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1536
+
1537
+ Groups: `Stroke` (`edge_`), `Stroke` (`whisker_`), `Stroke` (`median_`), `FillStyle`, `Marker` (`marker_`), `Font`.
1538
+ <!-- /settings -->
1539
+
1540
+ ### Heatmap
1541
+
1542
+ ```python
1543
+ pl.Heatmap(values, x=None, y=None, plot=None, **settings)
1544
+ ```
1545
+
1546
+ `values` is 2-D, row 0 first; a 3-D `(h, w, 3|4)` grid is drawn as colors. `x`/`y`:
1547
+ `None` (cell indices), labels (a category axis), n cell centres or n + 1 edges (uneven
1548
+ spacing and any axis scale allowed). `color_map` (alias `cmap`), `color_limits` and
1549
+ `color_scale` configure the series' [color axis](#6-color-and-size-axes).
1550
+ `value_labels=True` writes each value, formatted by `value_label_format` (any
1551
+ [number format](#number-formats); `"auto"`: 3 significant digits, the same decimals for
1552
+ all cells), in black or white, whichever contrasts more (at most 2,500 cells unless
1553
+ `value_labels="all"`). `kind`: `image`, `cells` or `smooth`.
1554
+
1555
+ <!-- settings:Heatmap -->
1556
+ | Setting | Default | Meaning |
1557
+ |---|---|---|
1558
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1559
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1560
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1561
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1562
+ | `kind` | 'image' | `image` (one image pixel per cell), `cells` (rectangles) or `smooth` (interpolated). |
1563
+ | `nan_color` | — | Color of missing cells; default: the map's `bad` (transparent). |
1564
+ | `origin` | 'top' | `top`: row 0 at the top (y axis inverted); `bottom`: at the bottom. |
1565
+ | `value_labels` | False | Write each cell's value (`"all"` above 2,500 cells). |
1566
+ | `value_label_format` | 'auto' | Number format of cell labels (`auto`: 3 significant digits, the same decimals for all cells). |
1567
+ | `value_label_font_size` | '0.9em' | Font size of cell labels. Length; `%`: of the font size. |
1568
+ | `colorbar` | False | Attach a colorbar to the plot. |
1569
+ | `name` | — | Legend entry; unset: not in the legend. |
1570
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
1571
+ | `z` | — | Drawing order (higher on top); default: call order. |
1572
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1573
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1574
+ | `text_color` | inherited ('black') | Text color. |
1575
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1576
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1577
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1578
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1579
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1580
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1581
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1582
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
1583
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
1584
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
1585
+ | `prefix` | inherited ('') | Text before every number. |
1586
+ | `suffix` | inherited ('') | Text after every number. |
1587
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
1588
+
1589
+ Groups: `TextStyle` (`value_label_`), `Font`, `NumberFormat`.
1590
+ <!-- /settings -->
1591
+
1592
+ ### Bar
1593
+
1594
+ ```python
1595
+ pl.Bar(x, height=None, plot=None, **settings)
1596
+ ```
1597
+
1598
+ `x`: categories (a category axis) or numbers (bars centred on them, `width` in data units); a dict `{category: height}`; or heights alone (at 0, 1, …). `value_labels` writes the values outside, inside or at the centre of the bars, formatted by `value_label_format`; `fill` is the opacity of the bars' fill (or a color); `error` adds error bars at the bar ends. Value axes include 0 (`include_zero="auto"`).
1599
+
1600
+ <!-- settings:Bar -->
1601
+ | Setting | Default | Meaning |
1602
+ |---|---|---|
1603
+ | `color` | — | Bar fill: a color, one per bar (list or dict by category), or numbers per bar (list or dict) mapped through `color_map`; default: the next palette color. |
1604
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1605
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1606
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1607
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1608
+ | `edge_color` | 'series' | Outline color: a color, `"series"` (each bar's own color, at `alpha`) or none. |
1609
+ | `edge_width` | 'var(line_width)' | Outline width. Length. |
1610
+ | `fill` | 0.25 | Fill: an opacity of each bar's color, times `alpha` (outlines keep `alpha`); `True` (opaque), a color, or `False`. |
1611
+ | `seam_color` | 'white' | Where outlined bars touch (dodged or adjacent), the shared edge in this color; `none`: both outlines as drawn. Between the parts of a stack, the line is the outline of the part nearer the baseline. |
1612
+ | `max_width` | — | Largest width of the series' part of a slot (as `width`); default none. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1613
+ | `width` | '80%' | Bar width: `%` of the slot, a length (bare numbers: px), `d` data units, or a duration (or `timedelta`) on time axes. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1614
+ | `bottom` | 0.0 | Base of the bars: a value or one per bar. |
1615
+ | `orientation` | 'vertical' | `vertical` (bars rise from the x axis) or `horizontal`. |
1616
+ | `stack` | False | `True`: on top of the previous stacked bars of the plot; `"normalize"`: stacks scaled to 1. |
1617
+ | `dodge` | True | Bar series sharing a category share its slot side by side; `False` overlays them. |
1618
+ | `gap` | 0.0 | Fraction of each bar's part of a shared slot left empty. Length; `%`: of each series' part of a shared slot. |
1619
+ | `saturation` | 1.0 | Saturation of the fills (seaborn: 0.75). |
1620
+ | `error` | — | Error bars at the bar ends: a value, a sequence, `(low, high)` or `ErrorBars`. |
1621
+ | `error_color` | '#333333' | Error bar color. |
1622
+ | `error_width` | 0.5 | Error bar line width. Length. |
1623
+ | `value_labels` | False | Value labels: `True`/`"outside"`, `"inside"`, `"center"`. Outside labels widen automatic limits so they fit in the axes; a label too large for its bar goes outside, or is left out on a stacked bar. |
1624
+ | `value_label_format` | 'auto' | Number format of the value labels. |
1625
+ | `name` | — | Legend entry; unset: not in the legend. |
1626
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
1627
+ | `z` | — | Drawing order (higher on top); default: call order. |
1628
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1629
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1630
+ | `text_color` | inherited ('black') | Text color. |
1631
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1632
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1633
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1634
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1635
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1636
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1637
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1638
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
1639
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
1640
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
1641
+ | `prefix` | inherited ('') | Text before every number. |
1642
+ | `suffix` | inherited ('') | Text after every number. |
1643
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
1644
+
1645
+ Groups: `Stroke` (`edge_`), `FillStyle`, `Stroke` (`error_`), `Font`, `NumberFormat`.
1646
+ <!-- /settings -->
1647
+
1648
+ ### Hist
1649
+
1650
+ ```python
1651
+ pl.Hist(values, plot=None, **settings)
1652
+ ```
1653
+
1654
+ `values`: one array, or several (a dict, a list of arrays) sharing the bins. `bins`: a count, edges, or numpy's rules (`auto` is numpy 2's). Bins are even on the axis scale (`bins_scale="axis"`): on a log axis, in log space. `stat` turns counts into densities (area 1), probabilities, percents or counts per unit; `cumulative` accumulates them. Several sets overlay (opacity 0.5), stack (`stack=True`) or dodge (`dodge=True`). `hist.stats`: `edges`, `counts` and `heights` per set.
1655
+
1656
+ <!-- settings:Hist -->
1657
+ | Setting | Default | Meaning |
1658
+ |---|---|---|
1659
+ | `bins` | 'auto' | A count, edges, or a rule: `auto`, `fd`, `sturges`, `scott`, `sqrt`, `rice`, `doane` (numpy's). |
1660
+ | `range` | — | Range of the bins; default the data range. |
1661
+ | `weights` | — | A weight per value (per set for several sets). |
1662
+ | `stat` | 'count' | `count`, `density` (area 1), `probability`, `percent` or `frequency` (count per unit). |
1663
+ | `cumulative` | False | Accumulate the bins. |
1664
+ | `kind` | 'stepfilled' | `bar` (adjacent bars), `step` (outline) or `stepfilled`. |
1665
+ | `bins_scale` | 'axis' | `axis`: bins even on the axis scale (log axes: in log space); `linear`: even in data units. |
1666
+ | `orientation` | 'vertical' | `vertical` (bins along x) or `horizontal`. |
1667
+ | `stack` | False | Stack the sets (and other stacked histograms with the same bins). |
1668
+ | `dodge` | False | Put the sets side by side within each bin. |
1669
+ | `color` | — | Fill color, or one per set; default palette colors. |
1670
+ | `edge_color` | — | Bar outline color; default none. |
1671
+ | `edge_width` | 0.0 | Bar outline width. Length. |
1672
+ | `line_color` | — | Step and outline color; default each set's color. |
1673
+ | `line_width` | inherited (0.5) | Step line width. Length. |
1674
+ | `outline` | True | `bar` and `stepfilled` kinds: the outer outline of each set, in `line_color` (dodged bars: each bar's outline). |
1675
+ | `alpha` | 'auto' | Opacity; `"auto"`: 0.5 for overlaid sets, else the plot's. |
1676
+ | `saturation` | 1.0 | Saturation of the fills. |
1677
+ | `value_labels` | False | Value labels on bars. |
1678
+ | `value_label_format` | 'auto' | Number format of the value labels. |
1679
+ | `name` | — | Legend entry; unset: not in the legend. |
1680
+ | `z` | — | Drawing order (higher on top); default: call order. |
1681
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1682
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1683
+ | `text_color` | inherited ('black') | Text color. |
1684
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1685
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1686
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1687
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1688
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1689
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1690
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1691
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
1692
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
1693
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
1694
+ | `prefix` | inherited ('') | Text before every number. |
1695
+ | `suffix` | inherited ('') | Text after every number. |
1696
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
1697
+
1698
+ Groups: `Stroke` (`edge_`), `Stroke` (`line_`), `Font`, `NumberFormat`.
1699
+ <!-- /settings -->
1700
+
1701
+ ### Kde
1702
+
1703
+ ```python
1704
+ pl.Kde(values, plot=None, **settings)
1705
+ ```
1706
+
1707
+ A Gaussian kernel density of each set on a common grid of `points` points, extending `cut` bandwidths past the data (within `range`). `fill` fills under each curve (`True`: at 0.25, an opacity, or a color). `bandwidth`: `scott` (default), `silverman` (as scipy's `gaussian_kde`) or a number, times `adjust`. On log axes the density is computed in log space, per log unit. `kde.stats`: `grid`, `densities`, `bandwidths`.
1708
+
1709
+ <!-- settings:Kde -->
1710
+ | Setting | Default | Meaning |
1711
+ |---|---|---|
1712
+ | `bandwidth` | 'scott' | `scott`, `silverman`, or a bandwidth in data units. |
1713
+ | `adjust` | 1.0 | Factor applied to the bandwidth. |
1714
+ | `cut` | 3.0 | The curve extends this many bandwidths past the data. |
1715
+ | `range` | — | Limits of the curve (within the data plus `cut`); default none. |
1716
+ | `points` | 512 | Number of points of the curve. |
1717
+ | `cumulative` | False | Plot the cumulative distribution. |
1718
+ | `fill` | False | Fill under the curve: an opacity of its color, `True` (0.25), a color, or `False` (stacked curves: 0.25). |
1719
+ | `weights` | — | A weight per value (per set for several sets). |
1720
+ | `orientation` | 'vertical' | `vertical` (values along x) or `horizontal`. |
1721
+ | `stack` | False | Stack the sets (seaborn's `multiple="stack"`). |
1722
+ | `color` | — | Color, or one per set; default palette colors. |
1723
+ | `line_width` | inherited (0.5) | Line width. Length. |
1724
+ | `line_style` | 'solid' | Line style. Length. |
1725
+ | `name` | — | Legend entry; unset: not in the legend. |
1726
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
1727
+ | `z` | — | Drawing order (higher on top); default: call order. |
1728
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1729
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1730
+ | `text_color` | inherited ('black') | Text color. |
1731
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1732
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1733
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1734
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1735
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1736
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1737
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1738
+
1739
+ Groups: `FillStyle`, `Stroke`, `Font`.
1740
+ <!-- /settings -->
1741
+
1742
+ ### Kde2d
1743
+
1744
+ ```python
1745
+ p.kde(x, y, levels=10, fill=False, thresh=0.05, **settings) # or pl.Kde(x, y), pl.Kde2d(x, y)
1746
+ ```
1747
+
1748
+ Density contours of points (seaborn's `kdeplot(x=, y=)`): the 2-D Gaussian density
1749
+ (bandwidth as [`Density`](#point-density): scipy's covariance times Scott's factor, or
1750
+ Silverman's, a number or a matrix, times `adjust`) on a `points` × `points` grid over
1751
+ the data plus `cut` bandwidths, in axis positions (log axes in log space). With a number
1752
+ of `levels`, contour k of n encloses an equal share of the mass, from 1 − `thresh` (the
1753
+ outermost) up; a list gives density values. Unfilled lines take the next palette color,
1754
+ or `palette` (one color or colors per level), unless `color_map` is set; `fill=True`
1755
+ colors the bands through
1756
+ `color_map`, with the top band up to the maximum. Drawn by the contour code (lines,
1757
+ labels, colorbar).
1758
+
1759
+ <!-- settings:Kde2d -->
1760
+ | Setting | Default | Meaning |
1761
+ |---|---|---|
1762
+ | `levels` | 10 | A number of iso-proportion levels (contour k of n encloses k/n of the mass, above `thresh`), or density values. |
1763
+ | `thresh` | 0.05 | Lowest iso-proportion: the outermost contour encloses 1 − `thresh` of the mass. |
1764
+ | `bandwidth` | 'scott' | `"scott"`, `"silverman"`, a number or a 2 × 2 matrix, as `Density`. |
1765
+ | `adjust` | 1.0 | Factor of the bandwidth. |
1766
+ | `cut` | 3.0 | Grid extends this many bandwidths past the data. |
1767
+ | `points` | 128 | Grid points per side. |
1768
+ | `colorbar` | False | Attach a colorbar to the plot. |
1769
+ <!-- /settings -->
1770
+
1771
+ ### Ecdf
1772
+
1773
+ ```python
1774
+ pl.Ecdf(values, plot=None, **settings)
1775
+ ```
1776
+
1777
+ A step line through the sorted values of each set: `stat` `proportion`, `count` or `percent`; `complementary` plots 1 − F.
1778
+
1779
+ <!-- settings:Ecdf -->
1780
+ | Setting | Default | Meaning |
1781
+ |---|---|---|
1782
+ | `weights` | — | A weight per value (per set for several sets). |
1783
+ | `stat` | 'proportion' | `proportion` (0–1), `count` or `percent`. |
1784
+ | `complementary` | False | Plot 1 − F (survival). |
1785
+ | `orientation` | 'vertical' | `vertical`: values along x; `horizontal`: along y. |
1786
+ | `color` | — | Line color, or one per set; default palette colors. |
1787
+ | `line_width` | inherited (0.5) | Line width. Length. |
1788
+ | `line_style` | 'solid' | Line style. Length. |
1789
+ | `name` | — | Legend entry; unset: not in the legend. |
1790
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
1791
+ | `z` | — | Drawing order (higher on top); default: call order. |
1792
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1793
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1794
+ | `text_color` | inherited ('black') | Text color. |
1795
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1796
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1797
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1798
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1799
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1800
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1801
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1802
+
1803
+ Groups: `Stroke`, `Font`.
1804
+ <!-- /settings -->
1805
+
1806
+ ### Violin
1807
+
1808
+ ```python
1809
+ pl.Violin(values, positions=None, plot=None, **settings)
1810
+ ```
1811
+
1812
+ `values` as box plots take them. Each violin is the density of its category, mirrored; `width_scale` gives equal areas (default), areas proportional to the counts, or equal widths. `inner` draws a thin box with whiskers and a median dot, dashed quartiles, the points, or nothing (`False`). With `split=True`, two violin series share each slot as facing halves.
1813
+
1814
+ <!-- settings:Violin -->
1815
+ | Setting | Default | Meaning |
1816
+ |---|---|---|
1817
+ | `color` | — | Fill: a color, one per violin (list or dict by category), or numbers per violin mapped through `color_map`; default the next palette color. |
1818
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1819
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1820
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1821
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1822
+ | `edge_color` | 'series' | Outline and inner color: a color or `"series"` (each violin's own color, at `alpha`). |
1823
+ | `edge_width` | 0.5 | Outline width. Length. |
1824
+ | `saturation` | 1.0 | Saturation of the fills. |
1825
+ | `alpha` | 1.0 | Opacity of the violins. |
1826
+ | `fill` | 0.25 | Fill: an opacity of each violin's color, times `alpha` (outlines keep `alpha`); `True` (opaque), a color, or `False`. |
1827
+ | `max_width` | — | Largest width of the series' part of a slot (as `width`); default none. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1828
+ | `width` | '80%' | Violin width: `%` of the slot, a length (bare numbers: px), `d` data units, or a duration on time axes. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1829
+ | `bandwidth` | 'scott' | `scott`, `silverman` or a number. |
1830
+ | `adjust` | 1.0 | Factor applied to the bandwidth. |
1831
+ | `cut` | 2.0 | The density extends this many bandwidths past the data. |
1832
+ | `points` | 512 | Points per violin outline. |
1833
+ | `width_scale` | 'area' | `area`: equal areas; `count`: area proportional to the number of values; `width`: equal widths. |
1834
+ | `inner` | 'box' | Inside each violin: `box` (a thin box, whiskers and a median dot), `quartiles` (dashed lines), `points`, or `False` (nothing). |
1835
+ | `split` | False | Two violin series share each slot as facing halves. |
1836
+ | `orientation` | 'vertical' | `vertical` (categories on x) or `horizontal`. |
1837
+ | `dodge` | True | Violin and box series sharing a category share its slot side by side; `False` overlays them. |
1838
+ | `gap` | '10%' | Fraction of each part of a shared slot left empty. Length; `%`: of each series' part of a shared slot. |
1839
+ | `categories` | — | Category names of a list of arrays. |
1840
+ | `name` | — | Legend entry; unset: not in the legend. |
1841
+ | `z` | — | Drawing order (higher on top); default: call order. |
1842
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1843
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1844
+ | `text_color` | inherited ('black') | Text color. |
1845
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1846
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1847
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1848
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1849
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1850
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1851
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1852
+
1853
+ Groups: `Stroke` (`edge_`), `FillStyle`, `Font`.
1854
+ <!-- /settings -->
1855
+
1856
+ ### Strip and swarm
1857
+
1858
+ ```python
1859
+ pl.Strip(values, positions=None, plot=None, **settings)
1860
+ pl.Swarm(values, positions=None, plot=None, **settings)
1861
+ ```
1862
+
1863
+ Points of each category's values: `Strip` spreads them by uniform jitter (± `jitter`, `%` of the slot width, from `seed`), `Swarm` places them side by side without overlaps (points that do not fit go to the slot edge, with a warning). Marker settings as `Scatter`. `Swarm` takes the same settings as `Strip` except `jitter` and `seed`.
1864
+
1865
+ <!-- settings:Strip -->
1866
+ | Setting | Default | Meaning |
1867
+ |---|---|---|
1868
+ | `marker` | 'circle' | Marker name, `Path` or path data, or one per point. |
1869
+ | `size` | 4.5 | Marker size: the diameter of the circle of equal area; one value or one per point; numbers per point are values to map when `size_map` is set; or `"density"`. Length. |
1870
+ | `color` | — | Fill: a color, colors per point, numbers per point (mapped through `color_map`) or `"density"`. |
1871
+ | `edge_color` | 'auto' | Outline: as the fill color, or `"auto"` (white around filled markers; hollow ones outlined in their color). |
1872
+ | `edge_width` | 0.5 | Outline width; 0: no outline. Length. |
1873
+ | `fill` | True | `True`: filled with the color; `False`: hollow, outlined in the color; an opacity (0–1): filled at that opacity and outlined in the color. |
1874
+ | `size_basis` | 'area' | `area`: shapes of the same size have the same area; `box`: size is the width of the shape's box. |
1875
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1876
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1877
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1878
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1879
+ | `size_map` | — | The sizes numbers in `size` are drawn with: a `SizeMap` (alias `smap`); without it (or `size_axis`), numbers are sizes in px. |
1880
+ | `size_limits` | — | Limits of the series' size axis, as an axis' `limits`; unset: `"auto"`. |
1881
+ | `size_scale` | — | Scale of the series' size axis; unset: `linear`. |
1882
+ | `size_axis` | — | A shared `SizeAxis` (`figure.size_axis(…)`) in place of the series' own: it holds the sizes, limits and scale. |
1883
+ | `size_legend` | True | With mapped sizes: a size key in the legend (`True`), none (`False`), or the values to show (a list). |
1884
+ | `orientation` | 'vertical' | `vertical` (categories on x) or `horizontal`. |
1885
+ | `max_width` | — | Largest width of the series' part of a slot (as `width`); default none. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1886
+ | `width` | '80%' | Width the points spread over: `%` of the slot, a length (bare numbers: px), `d` data units, or a duration on time axes. Length; `%`: of the slot: one category, or the smallest gap between positions; `d`: data units. |
1887
+ | `dodge` | True | Point series sharing a category share its slot side by side; `False` overlays them. |
1888
+ | `gap` | 0.0 | Fraction of each part of a shared slot left empty. Length; `%`: of each series' part of a shared slot. |
1889
+ | `categories` | — | Category names of a list of arrays. |
1890
+ | `jitter` | '10%' | Half-width of the jitter (`%` of the slot width). Length; `%`: of the slot: one category, or the smallest gap between positions. |
1891
+ | `seed` | 0 | Seed of the jitter. |
1892
+ | `draw_order` | — | Drawing order: `"density"` (densest drawn last), `"-density"`, or sort keys per point (ascending); default: call order. |
1893
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own; or `"density"` / a `Density`, mapped linearly to `alpha_range`. |
1894
+ | `alpha_range` | (0.2, 1.0) | Opacities of the least and most dense points when `alpha` is a density. |
1895
+ | `name` | — | Legend entry; unset: not in the legend. |
1896
+ | `z` | — | Drawing order (higher on top); default: call order. |
1897
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1898
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1899
+ | `text_color` | inherited ('black') | Text color. |
1900
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1901
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1902
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1903
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1904
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1905
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1906
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1907
+
1908
+ Groups: `Marker`, `Font`.
1909
+ <!-- /settings -->
1910
+
1911
+ ### Area
1912
+
1913
+ ```python
1914
+ pl.Area(x, ys, plot=None, **settings)
1915
+ ```
1916
+
1917
+ Layers (rows of `ys`, or a dict `{name: values}`, one legend entry each) stacked on `baseline`: `zero`, `sym`, `wiggle` or `weighted_wiggle` (matplotlib's stackplot baselines). `interpolation` and `missing` as `Fill`.
1918
+
1919
+ <!-- settings:Area -->
1920
+ | Setting | Default | Meaning |
1921
+ |---|---|---|
1922
+ | `baseline` | 'zero' | `zero`, `sym` (symmetric around 0), `wiggle` or `weighted_wiggle` (streamgraphs, as matplotlib's stackplot). |
1923
+ | `stack` | True | Stack the layers; `False` overlays them from 0. |
1924
+ | `color` | — | A color, or one per layer; default palette colors. |
1925
+ | `alpha` | 0.25 | Opacity of the fills. |
1926
+ | `edge_color` | 'series' | Outline color of each layer's top: a color, `"series"` (each layer's own color) or none. |
1927
+ | `edge_width` | 'var(line_width)' | Outline width; default the line width. Length. |
1928
+ | `interpolation` | 'linear' | How points are joined: `linear`, `step-pre`, `step-post`, `step-mid`, `monotone` (a curve that never overshoots) or `spline` (centripetal Catmull–Rom). |
1929
+ | `missing` | 'break' | Missing values: `break` the line there, or `skip` them and connect their neighbours. |
1930
+ | `orientation` | 'vertical' | `vertical` (layers along x) or `horizontal` (along y). |
1931
+ | `name` | — | Legend entry; unset: not in the legend. |
1932
+ | `z` | — | Drawing order (higher on top); default: call order. |
1933
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1934
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1935
+ | `text_color` | inherited ('black') | Text color. |
1936
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1937
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1938
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1939
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1940
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1941
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1942
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1943
+
1944
+ Groups: `Stroke` (`edge_`), `Font`.
1945
+ <!-- /settings -->
1946
+
1947
+ ### Errorbar
1948
+
1949
+ ```python
1950
+ pl.Errorbar(x, y, plot=None, **settings)
1951
+ ```
1952
+
1953
+ Error bars on their own (markers only with `marker=`); `y_error_style="band"` fills the band between the y error ends instead. Numbers in `marker_color` map through the series' color axis, as on [Line](#line).
1954
+
1955
+ <!-- settings:Errorbar -->
1956
+ | Setting | Default | Meaning |
1957
+ |---|---|---|
1958
+ | `marker` | — | Marker at the points; default none. |
1959
+ | `marker_size` | 4.5 | Marker size: the diameter of the circle of equal area, in px; one value or one per point. Length. |
1960
+ | `marker_color` | — | Fill: a color, colors per point, numbers per point (mapped through `color_map`) or `"density"`. |
1961
+ | `marker_edge_color` | 'auto' | Outline: as the fill color, or `"auto"` (white around filled markers; hollow ones outlined in their color). |
1962
+ | `marker_edge_width` | 0.5 | Outline width; 0: no outline. Length. |
1963
+ | `marker_fill` | True | `True`: filled with the color; `False`: hollow, outlined in the color; an opacity (0–1): filled at that opacity and outlined in the color. |
1964
+ | `size_basis` | 'area' | `area`: shapes of the same size have the same area; `box`: size is the width of the shape's box. |
1965
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
1966
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
1967
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
1968
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
1969
+ | `color` | — | Bar color; default: the next palette color. |
1970
+ | `line_width` | inherited (0.5) | Bar width. Length. |
1971
+ | `cap_length` | 4.0 | Cap width (`data`: in data units across the bar); 0: no caps. Length; `d`: data units. |
1972
+ | `x_error` | — | Horizontal errors. |
1973
+ | `y_error` | — | Vertical errors. |
1974
+ | `y_error_style` | 'bars' | `bars`, or `band`: a filled band between the y error ends (points sorted by x). |
1975
+ | `band_alpha` | 0.25 | Opacity of a band. |
1976
+ | `orientation` | 'vertical' | `vertical` (x along the x axis) or `horizontal` (x along the y axis). |
1977
+ | `name` | — | Legend entry; unset: not in the legend. |
1978
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
1979
+ | `z` | — | Drawing order (higher on top); default: call order. |
1980
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
1981
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
1982
+ | `text_color` | inherited ('black') | Text color. |
1983
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
1984
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
1985
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
1986
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
1987
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
1988
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
1989
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
1990
+
1991
+ Groups: `Marker` (`marker_`), `Font`.
1992
+ <!-- /settings -->
1993
+
1994
+ ### Stem
1995
+
1996
+ ```python
1997
+ pl.Stem(x, y=None, plot=None, **settings)
1998
+ ```
1999
+
2000
+ Stems from `baseline` to each value with a marker (lollipops), and a baseline line. Numbers in `marker_color` map through the series' color axis, as on [Line](#line).
2001
+
2002
+ <!-- settings:Stem -->
2003
+ | Setting | Default | Meaning |
2004
+ |---|---|---|
2005
+ | `marker` | 'circle' | Marker name, `Path` or path data, or one per point. |
2006
+ | `marker_size` | 5.0 | Marker size: the diameter of the circle of equal area, in px; one value or one per point. Length. |
2007
+ | `marker_color` | — | Fill: a color, colors per point, numbers per point (mapped through `color_map`) or `"density"`. |
2008
+ | `marker_edge_color` | — | Outline: as the fill color, or `"auto"` (white around filled markers; hollow ones outlined in their color). |
2009
+ | `marker_edge_width` | 0.0 | Outline width; 0: no outline. Length. |
2010
+ | `marker_fill` | True | `True`: filled with the color; `False`: hollow, outlined in the color; an opacity (0–1): filled at that opacity and outlined in the color. |
2011
+ | `size_basis` | 'area' | `area`: shapes of the same size have the same area; `box`: size is the width of the shape's box. |
2012
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
2013
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
2014
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
2015
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
2016
+ | `color` | — | Stem and marker color; default: the next palette color. |
2017
+ | `line_width` | inherited (0.5) | Stem width. Length. |
2018
+ | `baseline` | 0.0 | Value the stems start from. |
2019
+ | `baseline_color` | '#4d4d4d' | Baseline color; `none`: no baseline. |
2020
+ | `baseline_width` | 0.5 | Baseline width. Length. |
2021
+ | `orientation` | 'vertical' | `vertical` stems (values on y) or `horizontal`. |
2022
+ | `name` | — | Legend entry; unset: not in the legend. |
2023
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
2024
+ | `z` | — | Drawing order (higher on top); default: call order. |
2025
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
2026
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
2027
+ | `text_color` | inherited ('black') | Text color. |
2028
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
2029
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
2030
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
2031
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
2032
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
2033
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
2034
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
2035
+
2036
+ Groups: `Marker` (`marker_`), `Stroke` (`baseline_`), `Font`.
2037
+ <!-- /settings -->
2038
+
2039
+ ### Regression
2040
+
2041
+ ```python
2042
+ pl.Regression(x, y, plot=None, **settings)
2043
+ ```
2044
+
2045
+ A least-squares polynomial of `order` with the confidence band of the mean (Student's t), or a LOWESS curve (`lowess=True`, no band); `logx` fits against log x; `range` sets the x range of the polynomial curve (default the data's), drawn in `points` points. The points are drawn too unless `scatter=False` (marker settings with the `marker_` prefix; numbers in `marker_color` map through the series' color axis, as on [Line](#line)). `regression.stats`: `coefficients` (lowest power first), `r2`, `se`, and the curve.
2046
+
2047
+ <!-- settings:Regression -->
2048
+ | Setting | Default | Meaning |
2049
+ |---|---|---|
2050
+ | `order` | 1 | Polynomial order (1–5). |
2051
+ | `lowess` | False | Fit a LOWESS curve instead (no band). |
2052
+ | `frac` | 0.6666666666666666 | Fraction of the points in each LOWESS fit. |
2053
+ | `ci` | 95.0 | Confidence level of the band (%); `None`: no band. |
2054
+ | `logx` | False | Fit y against log(x) (x > 0). |
2055
+ | `scatter` | True | Draw the points too. |
2056
+ | `range` | — | x range of the fitted polynomial (and band); default the data range. |
2057
+ | `points` | 100 | Points of the fitted curve. |
2058
+ | `color` | — | Line, band and point color; default the next palette color. |
2059
+ | `line_width` | 'calc(1.4 * inherit)' | Line width; default 1.4 × the plot's. Length. |
2060
+ | `line_style` | 'solid' | Line style or dash list. Length. |
2061
+ | `band_alpha` | 0.2 | Opacity of the band. |
2062
+ | `marker` | 'circle' | Marker name, `Path` or path data, or one per point. |
2063
+ | `marker_size` | 4.5 | Marker size: the diameter of the circle of equal area, in px; one value or one per point. Length. |
2064
+ | `marker_color` | — | Fill: a color, colors per point, numbers per point (mapped through `color_map`) or `"density"`. |
2065
+ | `marker_edge_color` | 'auto' | Outline: as the fill color, or `"auto"` (white around filled markers; hollow ones outlined in their color). |
2066
+ | `marker_edge_width` | 0.5 | Outline width; 0: no outline. Length. |
2067
+ | `marker_fill` | True | `True`: filled with the color; `False`: hollow, outlined in the color; an opacity (0–1): filled at that opacity and outlined in the color. |
2068
+ | `size_basis` | 'area' | `area`: shapes of the same size have the same area; `box`: size is the width of the shape's box. |
2069
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
2070
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
2071
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
2072
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
2073
+ | `orientation` | 'vertical' | `vertical` (y on x) or `horizontal` (the fit drawn with x along the y axis). |
2074
+ | `name` | — | Legend entry; unset: not in the legend. |
2075
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
2076
+ | `z` | — | Drawing order (higher on top); default: call order. |
2077
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
2078
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
2079
+ | `text_color` | inherited ('black') | Text color. |
2080
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
2081
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
2082
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
2083
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
2084
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
2085
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
2086
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
2087
+
2088
+ Groups: `Stroke`, `Marker` (`marker_`), `Font`.
2089
+ <!-- /settings -->
2090
+
2091
+ ### Hist2d
2092
+
2093
+ ```python
2094
+ pl.Hist2d(x, y, plot=None, **settings)
2095
+ ```
2096
+
2097
+ Counts in rectangular bins (even on the axis scales), drawn as a heatmap with the heatmap's settings; bins below `min_count` are transparent; a colorbar source.
2098
+
2099
+ <!-- settings:Hist2d -->
2100
+ | Setting | Default | Meaning |
2101
+ |---|---|---|
2102
+ | `bins` | ('auto', 'auto') | Bins of both axes, or `(x bins, y bins)`: counts, edges or rules (as `Hist`). |
2103
+ | `range` | — | `((x0, x1), (y0, y1))`; default the data range. |
2104
+ | `weights` | — | A weight per point. |
2105
+ | `stat` | 'count' | `count`, `density` (volume 1), `probability` or `percent`. |
2106
+ | `min_count` | 1.0 | Bins below this count are transparent. |
2107
+ | `origin` | 'bottom' | Row of the first y bin. |
2108
+ <!-- /settings -->
2109
+
2110
+ ### Hexbin
2111
+
2112
+ ```python
2113
+ pl.Hexbin(x, y, plot=None, **settings)
2114
+ ```
2115
+
2116
+ Counts in regular hexagons: `bins` hexagons across the axes width, on a lattice laid out
2117
+ in page units for the axes the layout places, so the hexagons tile exactly whatever the
2118
+ axes' aspect. The counts depend on the axes, and the color axis on the counts: the layout
2119
+ counts again when a round places the axes differently ([layout](#layout)). Points outside
2120
+ the axes are not counted. Colored by `cmap`; a colorbar source.
2121
+
2122
+ <!-- settings:Hexbin -->
2123
+ | Setting | Default | Meaning |
2124
+ |---|---|---|
2125
+ | `bins` | 30 | Hexagons across the axes width. |
2126
+ | `weights` | — | A weight per point (sums). |
2127
+ | `stat` | 'count' | `count`, `probability` or `percent`. |
2128
+ | `min_count` | 1.0 | Hexagons below this count are not drawn. |
2129
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
2130
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
2131
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
2132
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
2133
+ | `edge_color` | — | Hexagon outline color; default none. |
2134
+ | `edge_width` | 0.0 | Outline width. Length. |
2135
+ | `colorbar` | False | Attach a colorbar to the plot. |
2136
+ | `name` | — | Legend entry; unset: not in the legend. |
2137
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
2138
+ | `z` | — | Drawing order (higher on top); default: call order. |
2139
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
2140
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
2141
+ | `text_color` | inherited ('black') | Text color. |
2142
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
2143
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
2144
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
2145
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
2146
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
2147
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
2148
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
2149
+
2150
+ Groups: `Stroke` (`edge_`), `Font`.
2151
+ <!-- /settings -->
2152
+
2153
+ ### Contour
2154
+
2155
+ ```python
2156
+ pl.Contour(values, x=None, y=None, plot=None, **settings)
2157
+ ```
2158
+
2159
+ Iso-lines (`lines`) and filled bands (`fill`) of a grid at nodes `x`/`y`. `levels`: a number of nice values over the data, or the values. Lines take the map's colors, or `palette` (one color, or colors per level in turn: a list or a palette name); `negative_style` dashes negative levels drawn in one color; `value_labels` writes the levels on the lines. Bands are colored by their middle value.
2160
+
2161
+ <!-- settings:Contour -->
2162
+ | Setting | Default | Meaning |
2163
+ |---|---|---|
2164
+ | `levels` | 10 | A number of levels (nice values over the data) or the level values. |
2165
+ | `fill` | False | Fill the bands between levels: `True`, an opacity (0–1, times `alpha`), or `False`. |
2166
+ | `lines` | True | Draw the iso-lines. |
2167
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
2168
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
2169
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
2170
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
2171
+ | `palette` | — | Line color, or colors taken per level in turn (a list or a palette name), instead of the map. |
2172
+ | `line_width` | 'calc(0.6 * inherit)' | Line width; default 0.6 × the plot's. Length. |
2173
+ | `line_style` | 'solid' | Line style. Length. |
2174
+ | `negative_style` | — | Line style of negative levels drawn with a single color (matplotlib: dashed). |
2175
+ | `alpha` | 1.0 | Opacity. |
2176
+ | `value_labels` | False | Write the level values on the lines. |
2177
+ | `value_label_format` | 'auto' | Number format of the value labels. |
2178
+ | `value_label_font_size` | '0.8em' | Label font size. Length; `%`: of the font size. |
2179
+ | `colorbar` | False | Attach a colorbar to the plot. |
2180
+ | `name` | — | Legend entry; unset: not in the legend. |
2181
+ | `z` | — | Drawing order (higher on top); default: call order. |
2182
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
2183
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
2184
+ | `text_color` | inherited ('black') | Text color. |
2185
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
2186
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
2187
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
2188
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
2189
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
2190
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
2191
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
2192
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
2193
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
2194
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
2195
+ | `prefix` | inherited ('') | Text before every number. |
2196
+ | `suffix` | inherited ('') | Text after every number. |
2197
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
2198
+
2199
+ Groups: `FillStyle`, `Stroke`, `TextStyle` (`value_label_`), `Font`, `NumberFormat`.
2200
+ <!-- /settings -->
2201
+
2202
+ ### Pie
2203
+
2204
+ ```python
2205
+ pl.Pie(values, plot=None, **settings)
2206
+ ```
2207
+
2208
+ Wedges of `values` (a sequence or a dict `{label: value}`) from `start`, on a plot drawn without axes (`Plot.axes=False`, aspect 1). `hole` makes a donut (`"40%"` of the radius), `explode` moves wedges out (`%` of the radius, one value or one per wedge). Names go outside (pushed apart so that they do not overlap), inside, or into the legend (`name_position="none"`, the legend then outside right); `palette` colors them in turn; `value_labels` writes percents or values inside, or outside with a leader line when a wedge is too thin.
2209
+
2210
+ <!-- settings:Pie -->
2211
+ | Setting | Default | Meaning |
2212
+ |---|---|---|
2213
+ | `names` | — | Wedge names (default: the dict's keys). |
2214
+ | `palette` | — | Wedge colors, taken in turn: a list of colors or a palette name; default the plot's palette. |
2215
+ | `start` | 90.0 | Angle where the first wedge starts (degrees, 0: 3 o'clock, 90: 12 o'clock). Angle (bare: degrees). |
2216
+ | `counterclockwise` | True | Direction of the wedges. |
2217
+ | `hole` | 0.0 | Radius of the hole (`%` of the radius): a donut. Length; `%`: of the radius. |
2218
+ | `explode` | — | Offset of the wedges from the centre (`%` of the radius): one value or one per wedge. Length; `%`: of the radius. |
2219
+ | `sort` | False | Sort the wedges by decreasing value. |
2220
+ | `name_position` | 'outside' | Where the names go: `outside`, `inside` or `none` (in the legend instead). |
2221
+ | `value_labels` | False | Write each wedge's `percent` or `value` inside it (outside, with a leader line, when it does not fit). |
2222
+ | `label_spacing` | '1.25em' | Smallest distance between outside labels on a side. Length; `%`: of the font size. |
2223
+ | `value_label_format` | 'auto' | Number format of the value labels (percentages: of 100). |
2224
+ | `edge_color` | 'series' | Wedge outline color: a color, `"series"` (each wedge's own color) or `none`. |
2225
+ | `edge_width` | 1.25 | Wedge outline width. Length. |
2226
+ | `alpha` | 1.0 | Opacity. |
2227
+ | `fill` | 0.25 | Wedge fill: an opacity of each wedge's color, times `alpha` (outlines keep `alpha`); `True` (opaque), a color, or `False`. |
2228
+ | `seam_color` | 'white' | The edges neighbouring wedges share, in this color; `none`: both outlines as drawn. |
2229
+ | `name` | — | Legend entry; unset: not in the legend. |
2230
+ | `z` | — | Drawing order (higher on top); default: call order. |
2231
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
2232
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
2233
+ | `text_color` | inherited ('black') | Text color. |
2234
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
2235
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
2236
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
2237
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
2238
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
2239
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
2240
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
2241
+ | `decimal_separator` | inherited ('.') | Decimal separator of numbers (`"."`). |
2242
+ | `thousands_separator` | inherited ('') | Thousands separator (`""`: none). |
2243
+ | `minus` | inherited ('hyphen') | `hyphen` (`-`) or `minus` (U+2212, from an installed font). |
2244
+ | `prefix` | inherited ('') | Text before every number. |
2245
+ | `suffix` | inherited ('') | Text after every number. |
2246
+ | `precision` | inherited (None) | Significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed). |
2247
+
2248
+ Groups: `Stroke` (`edge_`), `FillStyle`, `Font`, `NumberFormat`.
2249
+ <!-- /settings -->
2250
+
2251
+ ## 6. Color and size axes
2252
+
2253
+ Numbers given as colors (per point, per cell, per category, or a density) go through a
2254
+ **color axis** before they become colors, as positions go through an x axis: its scale
2255
+ and limits take each value to [0, 1], and its gradient (a `ColorMap`) gives the color.
2256
+ Sizes go through a **size axis** the same way, with a `SizeMap` (diameters) in place of
2257
+ the gradient. A colorbar is the guide of a color axis, a size key that of a size axis.
2258
+
2259
+ ```python
2260
+ h = p.heatmap(v, cmap="magma", color_limits="q:0.01/q:0.99", color_scale="log")
2261
+ h.color_axis # the series' own color axis
2262
+ ca = fig.color_axis(color_map="magma", limits="0/max") # a shared one
2263
+ p.heatmap(v, color_axis=ca)
2264
+ q.scatter(x, y, c=z, color_axis=ca)
2265
+ fig.colorbar(ca, id=5, label="energy")
2266
+ fig = pl.Figure(cols=3, share_color="row") # each row's plots: one color axis
2267
+ fig = pl.Figure(cols=3, share_size="all") # one size axis, one size key
2268
+ ```
2269
+
2270
+ * **Own axes.** A series that maps values has its own color axis, `series.color_axis`
2271
+ (and size axis, `series.size_axis`). Its `scale` is the series' `color_scale`, its
2272
+ `limits` the series' `color_limits` (axis syntax: `"auto"`, the values' range;
2273
+ `"0/max"`, `"q:0.01/q:0.99"`, `[lo, hi]`), its gradient the series' `color_map`
2274
+ (inherited: the plot's, the figure's, the style's). Its other settings (ticks,
2275
+ `tick_format`, `label`, fonts) are drawn by its colorbar. A `scale` or `limits` set on
2276
+ the axis itself wins over the series' settings.
2277
+ * **Shared axes.** `fig.color_axis(**settings)` (`fig.size_axis(**settings)`) makes an
2278
+ axis that series take as `color_axis=` (`size_axis=`). It holds the gradient
2279
+ (`color_map`; sizes: `size_map`), the scale and the limits; its automatic limits cover
2280
+ every series using it, and those series take no `color_map`, `color_limits` or
2281
+ `color_scale` of their own (an error). A `pl.ColorAxis(**settings)` made alone joins
2282
+ the figure of the first series given it. The members of a `group=` call share one axis
2283
+ of each kind.
2284
+ * **`share_color`.** The figure's `share_color` (`False`, `True`/`"all"`, `"col"` or
2285
+ `"row"`, as `share_x`) makes the own color axes of each group's plots one axis: limits
2286
+ over all their values; one `color_limits` (or scale) applies to the group, two
2287
+ different ones are an error. Each series keeps its gradient. Facet figures share
2288
+ color this way (`"all"` by default).
2289
+ * **`share_size`** does the same for the own size axes: limits over all the group's
2290
+ values, one `size_limits` (or `size_scale`) for the group, and one size key for the
2291
+ group ([legend](#legend)). Each series keeps its `size_map`. Facet figures share size
2292
+ too (`"all"`). A figure legend covering every plot of a key takes the key.
2293
+ * **Training.** Before the layout, each axis is resolved from the values it maps, by the
2294
+ code of x and y axes: the scale's domain, `limits` and quantiles, `include_zero`, no
2295
+ padding (unless `padding` is set). Values past the limits take the gradient's
2296
+ `under`/`over` colors and missing values its `bad` color (sizes: the `SizeMap`'s).
2297
+
2298
+ Color and size axes have the settings of [axes](#4-axes); these differ:
2299
+
2300
+ <!-- settings:ColorAxis -->
2301
+ | Setting | Default | Meaning |
2302
+ |---|---|---|
2303
+ | `scale` | — | Scale of the mapped values: `linear`, `log`, `log2`, `log10`, `sqrt`, `exp`, `symlog` or `logit`; default `linear`. |
2304
+ | `color_map` | inherited ('rainbow_llhh') | The gradient: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
2305
+ <!-- /settings -->
2306
+
2307
+ <!-- settings:SizeAxis -->
2308
+ | Setting | Default | Meaning |
2309
+ |---|---|---|
2310
+ | `scale` | — | Scale of the mapped values: `linear`, `log`, `log2`, `log10`, `sqrt`, `exp`, `symlog` or `logit`; default `linear`. |
2311
+ | `size_map` | — | The sizes: a `SizeMap` or a pair of diameters; default `SizeMap()`. |
2312
+ <!-- /settings -->
2313
+
2314
+ ### Colorbars
2315
+
2316
+ ```python
2317
+ p.colorbar(source=None, side="bottom", **settings) # attached to a side of the plot
2318
+ fig.add_colorbar(source=None, plots=None, side="bottom", **settings) # beside plots
2319
+ fig.colorbar(source, id=None, **settings) # in its own grid area
2320
+ fig.colorbars # those of add_colorbar
2321
+ cb.axis # the color axis shown
2322
+ ```
2323
+
2324
+ `source` is a mapped series (its color axis; default: the plot's last mapped series, or
2325
+ that of the first covered plot with one) or a color axis. A colorbar draws the axis'
2326
+ gradient between its trained limits, with a label: `label`, else the axis' `label`, else
2327
+ the name of the color column or density.
2328
+
2329
+ * **Key** (`style="key"`, the default): one line of the low limit, a short bar with round
2330
+ ends filled with the gradient (`thickness` 4 px, `length` 40 px), the high limit, then
2331
+ the label; `value_gap` (0.6em) between a limit and the bar, `label_gap` (1.2em) before
2332
+ the label. The texts are centered on the bar's middle line, in the axis' tick label font
2333
+ (the label in its label font); `em` is the axis' tick label font size. When the limits
2334
+ clip the data (`extend`), a dot as wide as the bar, in the gradient's under or over
2335
+ color, sits half the thickness past that end (`extend_shape`: `dot`, `block`,
2336
+ `triangle`). `frame` outlines the bar and the dots, following their shapes.
2337
+ * **Values.** `values="limits"`: the axis' limits in its `tick_format` (`"auto"`: rounded
2338
+ to two digits of their range); `"ticks"`: the axis' ticks along the bar instead, under
2339
+ it (right of a vertical one); `"signs"`: a bold − (always U+2212, whatever `minus`) and
2340
+ a bold +; or a pair of texts with markup, `("Low", "High")`, `None` keeping that end's
2341
+ number: `(None, "max")`.
2342
+ * **Vertical** (on the left and right): the high limit above the bar, the low limit below
2343
+ it, the label above everything, horizontal, all centered on the bar.
2344
+ `label_position`: `end` (after the high end; above a vertical key), `start` (before
2345
+ the low end; below a vertical key), `top` (above the key), `side` (under a horizontal
2346
+ key; beside a vertical one, reading upward).
2347
+ * **Bar** (`style="bar"`): a long bar (`length` `100%`, `thickness` 13 px) with the axis'
2348
+ ticks, tick labels and label beside it, for many ticks (log scales, diverging maps).
2349
+ `values`, the gaps and `label_position` are a key's.
2350
+ * **Attached.** A band of the plot's box on its `side` (default `bottom`;
2351
+ `orientation="auto"`: horizontal on top and bottom, vertical on the left and right),
2352
+ placed along the side by `align` (`"auto"`: the end on top and bottom, the center on
2353
+ the left and right). On one side, from the axes outward: an outside legend, the
2354
+ colorbars (by `order`, else in creation order), the titles. A key longer than its axes
2355
+ side passes its ends, and the margins there grow.
2356
+ * **Lanes.** `fig.add_colorbar` puts a colorbar beside a set of plots (plots or their
2357
+ series; default every plot) in the lanes of [figure titles](#figure-title) and
2358
+ [legends](#figure-legends), with their rules (the plots' grid rectangle, nesting, shared
2359
+ lanes for disjoint spans, creation order, `order`); over the same plots, a legend is
2360
+ nearer the plots, then a colorbar, then a title. `align` (default `center`) places it
2361
+ within the axes of its plots. A `%` `length` is of that span, and a key then fills
2362
+ that part of it (`length="100%"`: the bar takes what the texts leave of the span). The
2363
+ covered plots' attached colorbars of the same axis are left out.
2364
+ * **Shared color axes.** When plots sharing a color axis have attached colorbars of it,
2365
+ one colorbar in the lanes replaces them: per group of `share_color`, on the right of a
2366
+ row or of the figure, at the bottom of a column; then per axis that the attached
2367
+ colorbars of two plots or more show (`fig.color_axis()`), at the bottom of a column,
2368
+ else on the right. It takes the settings of the first one but its place. An attached
2369
+ colorbar whose `side` is set stays, as do those of plots that are not a grid
2370
+ rectangle.
2371
+ * **Own area.** `fig.colorbar(source, id=…)` is vertical in its grid area (`orientation`):
2372
+ a key placed along it by `align`, a bar running along the neighbouring axes
2373
+ (`align="axes"`) or boxes (`"borders"`).
2374
+ * `p.save()` (one plot alone) leaves out figure colorbars: the plot's attached colorbars
2375
+ show again.
2376
+
2377
+ Axis settings given to a colorbar go to its axis:
2378
+ `p.colorbar(h, label="z", tick_format="{:.0%}")` sets `h.color_axis`'s tick format.
2379
+
2380
+ <!-- settings:Colorbar -->
2381
+ | Setting | Default | Meaning |
2382
+ |---|---|---|
2383
+ | `side` | 'bottom' | Side of the plot (or of the plots) it sits on. |
2384
+ | `align` | 'center' | Place along its side: `start` (left, or top), `center`, `end` (right, or bottom). |
2385
+ | `order` | — | Place among the colorbars of its side: lower is nearer the axes; unset: creation order. |
2386
+ | `style` | 'key' | `key`: one line of the limits around a short bar with round ends, then the label; `bar`: a long bar with the axis' ticks. |
2387
+ | `orientation` | 'auto' | Direction; `"auto"`: horizontal on top and bottom, vertical on the left and right and in an area of its own. |
2388
+ | `thickness` | 'auto' | Bar thickness; `"auto"`: 4 px on a key, 13 px on a bar. Length; `%`: of the span along a key, the axes side across a bar. |
2389
+ | `length` | 'auto' | Bar length; `"auto"`: 40 px on a key, `100%` on a bar. A key given in `%` fills that part of the span with its texts and bar. Length; `%`: of the span along the colorbar (the axes side of an attached one). |
2390
+ | `values` | 'limits' | A key's end texts: `limits` (the axis' limits in its `tick_format`), `ticks` (the axis' ticks along the bar, lengthened to show at least two), `signs` (a bold − and +) or a pair of texts (`None`: that end's number). |
2391
+ | `value_gap` | '0.6em' | Gap between a key's end texts and its bar (and above or below a label on top or under it). Length; `%`: of the font size. |
2392
+ | `label_gap` | '1.2em' | Gap between a key's texts and its label, along the key. Length; `%`: of the font size. |
2393
+ | `label_position` | 'end' | A key's label: after the high end (`end`; above a vertical key), before the low end (`start`; below a vertical key), beside the bar (`side`: under a horizontal key, rotated right of a vertical one) or above the key (`top`). |
2394
+ | `pad` | 'auto' | Gap between the axes and an attached colorbar; `"auto"`: 0.8em on a key, 11 px on a bar. Length; `%`: of the axes side across the colorbar. |
2395
+ | `label` | — | Label: a string or rich content; default: the axis' `label`, else the name of the color column or density. |
2396
+ | `extend` | 'auto' | Ends in the under/over colors: `auto` shows them when the limits clip the data. |
2397
+ | `extend_shape` | 'auto' | `dot`: a dot past the key's end; `block`: a separate block at the end (within a bar's length); `triangle`: a triangle past the end; `"auto"`: `dot` on a key, `block` on a bar. |
2398
+ | `frame` | False | Outline the bar (and its ends), following its shape. |
2399
+ | `frame_color` | '#666666' | Outline color. |
2400
+ | `frame_width` | 0.5 | Outline width. Length. |
2401
+
2402
+ Groups: `Stroke` (`frame_`).
2403
+ <!-- /settings -->
2404
+
2405
+ Figure colorbars (`fig.add_colorbar`) have the settings of colorbars, and:
2406
+
2407
+ <!-- settings:FigureColorbar -->
2408
+ | Setting | Default | Meaning |
2409
+ |---|---|---|
2410
+ | `order` | — | Place in its side's lanes, as figure titles' `order`: lower is nearer the plots. |
2411
+ | `pad` | 'auto' | Gap between the colorbar and the plots; `"auto"`: 0.8em on a key, 11 px on a bar. Length. |
2412
+ <!-- /settings -->
2413
+
2414
+ ## 7. Colors, maps and markers
2415
+
2416
+ ### Colors and palette
2417
+
2418
+ Colors are anything vec_io accepts (CSS names, `#hex`, `(r, g, b[, a])` floats,
2419
+ `CMYK`, `Spot`) or `"C0"`, `"C1"`, … for palette entries; `"none"` paints nothing. The
2420
+ default palette (`"tab10_custom"`, `plot_io.color.palettes.PALETTE`) is tab10's ten hues as named colors: sky,
2421
+ amber, emerald, rose, purple 0.4, yellow 0.7, pink 0.4, gray, lime, cyan.
2422
+
2423
+ `palette` takes a `pl.Palette`, a registered name (`"tab10"`; `"tab10_r"` reversed), a
2424
+ list of colors (or one comma-separated string: `"red, teal 0.7"`), or a function `n -> colors`, called with the number of series of the plot
2425
+ that take a palette color.
2426
+
2427
+ ```python
2428
+ pl.Palette(colors="tab10_custom", name=None) # a name, colors, a Palette or n -> colors
2429
+ pl.register_palette(name, palette) # a Palette, colors or a function
2430
+ pl.palette_names()
2431
+ ```
2432
+
2433
+ | `Palette` | |
2434
+ |---|---|
2435
+ | `colors(n=None)` | the colors: all, or `n` (a list repeats, as series reuse it; a function is called with `n`) |
2436
+ | `len(p)`, `p[i]`, `p[a:b]`, `iter(p)` | lists only: count; a color (indices wrap); a sub-palette |
2437
+ | `reversed()`, `lighter(k=0.25)`, `darker(k=0.25)` | copies: reversed; each color moved by `k` toward white or black in Oklab |
2438
+
2439
+ `ColorMap.to_palette(n)` samples a gradient into `n` colors, at the centers of `n` equal
2440
+ parts: `palette=pl.ColorMap("viridis").to_palette(5)` for ordered categories.
2441
+
2442
+ | Palette | Colors |
2443
+ |---|---|
2444
+ | `tab10_custom` | plot_io's default: tab10's hues as named colors (10) |
2445
+ | `okabe_ito` | Okabe–Ito's eight colorblind-safe colors plus indigo and dark brown, chosen as the pair farthest from every other color (in Oklab) under normal and simulated protan, deutan and tritan vision (10) |
2446
+ | `tab10` | matplotlib ≥ 2.0, d3's category10 (10) |
2447
+ | `matplotlib_classic` | matplotlib 1.x: b, g, r, c, m, y, k (7) |
2448
+ | `tableau10` | Vega-Lite's default (10) |
2449
+ | `deep`, `muted`, `pastel`, `bright`, `dark`, `colorblind` | seaborn (10 each) |
2450
+ | `hue` | ggplot2's `hue_pal()`: n hues 360/n apart from 15°, chroma 100, luminance 65 (CIE LCh(uv)) |
2451
+ | `matlab` | MATLAB R2014b+ `lines` (7) |
2452
+ | `chartjs` | Chart.js 4 (7) |
2453
+ | `plotly` | plotly's default colorway (10) |
2454
+ | `observable10` | Observable Plot (d3's observable10) (10) |
2455
+ | `office` | Excel 2013+ Office theme (10) |
2456
+ | `economist` | The Economist (ggthemes, pre-2017) (10) |
2457
+ | `fivethirtyeight` | matplotlib's fivethirtyeight style (6) |
2458
+ | `greys` | black to light grey (4) |
2459
+ | `set1`, `set2`, `set3`, `paired`, `accent`, `dark2`, `pastel1`, `pastel2` | ColorBrewer's qualitative schemes by Brewer (Apache-2.0) (8–12) |
2460
+ | `batlow`, `batlowk`, `batloww`, `devon`, `lajolla`, `bamako`, `davos`, `bilbao`, `nuuk`, `oslo`, `grayc`, `hawaii`, `lapaz`, `tokyo`, `buda`, `acton`, `turku`, `imola`, `glasgow`, `lipari`, `navia` | Crameri's categorical Scientific colour maps 8 (MIT): the first colors differ most (100) |
2461
+
2462
+ ### Color maps
2463
+
2464
+ ```python
2465
+ pl.ColorMap(colors="rainbow_llhh", positions=None, under=None, over=None, bad=None,
2466
+ space=None, name=None, interpolation=None, widen_colors=1, widen_sides=1.0)
2467
+ pl.register_color_map(name, color_map)
2468
+ pl.color_map_names()
2469
+ ```
2470
+
2471
+ | Member | |
2472
+ |---|---|
2473
+ | `colors` | a name (`viridis`, `magma`, `inferno`, `plasma`, `cividis`, `coolwarm`, `grey`, `rocket`, `mako`, `flare`, `crest`, `vlag`, `icefire`, `jet`, `parula`, `turbo`, `ggplot2`, the rainbows, ColorBrewer's and Crameri's maps below, in any case (`"RdBu"`, `"batlowK"`); `_r` reverses), a list of colors (evenly spaced or at `positions`; or one string, comma-separated: `"violet 0.4, sky 0.4, green 0.4"`), a `ColorMap` (copied) or a function `t -> color` |
2474
+ | `under`, `over`, `bad` | colors below 0 and above 1, past the color axis' limits (default: the end colors), and of missing values (default: transparent) |
2475
+ | `space` | interpolation between the colors: `"oklab"` (default, for every map: perceptually even) or `"srgb"` |
2476
+ | `interpolation` | `"linear"` (default): between neighboring colors; `"nearest"`: equal steps, one per color (`n` colors, `n` bins; with `positions`, each step starts at its position; a value on an edge takes the upper step); `"smooth"`: a Bézier curve with the colors as control points, through the first and last only (no `positions`); `"spline"`: a monotone cubic curve through every color (PCHIP in Oklab: no overshoot between colors) |
2477
+ | `widen_colors`, `widen_sides` | each inner color of a list repeated `widen_colors` times, each end color `round(widen_sides × widen_colors)` times: wider bands around the colors |
2478
+ | `cm(t)`, `colors_at(ts)` | color at t ∈ [0, 1]; bulk colors (C: continuous maps through a table of 4,096 colors, steps exactly) |
2479
+ | `table(n)`, `cells(values, lo, hi, mode)` | n colors sampled evenly; what heatmap cells hand vec_io's `draw_cells` (C): palette indices into `table(255)` (`table(253)` plus the under and over colors), or for `smooth` positions along `table(256)` (steps: the step colors and their bounds) |
2480
+ | `reversed()`, `resampled(n)`, `truncated(lo, hi)`, `with_extremes(…)` | copies: reversed; n flat steps; a part stretched to [0, 1]; new extremes |
2481
+ | `to_palette(n)` | a `Palette` of `n` colors sampled at the centers of `n` equal parts |
2482
+
2483
+ Bundled data: viridis, magma, inferno and plasma by van der Walt and Smith (CC0); cividis
2484
+ by Nuñez, Anderton and Renslow; coolwarm by Moreland; rocket, mako, flare, crest, vlag and
2485
+ icefire from seaborn by Waskom (BSD-3-Clause); jet from matplotlib; a parula-like map;
2486
+ turbo by Mikhailov (Google, Apache-2.0);
2487
+ the rainbows, built from named colors with `widen_colors=6, widen_sides=0.6` and
2488
+ `interpolation="smooth"` (violet, sky,
2489
+ green, yellow, orange, rose): `rainbow` (all at level 0.4), `rainbow_neutral` (0.5),
2490
+ `rainbow_l0hh` (from white, then levels 0.1 to 0.6), `rainbow_llhh` (0.16 to 0.6),
2491
+ `rainbow_llh` (0.16 to 0.4), `rainbow_hlh` (dark ends, light middle); diverging maps from
2492
+ named colors: `blue_white_red` (sky, white, rose), `blue_white_red_hc` (levels 0.6 at the
2493
+ ends), `blue_gray_red` (a gray 0.2 middle), `blue_gray_red_hc`;
2494
+ ColorBrewer's schemes by Brewer (Apache-2.0): sequential `blues`, `bugn`, `bupu`, `gnbu`,
2495
+ `greens`, `greys`, `oranges`, `orrd`, `pubu`, `pubugn`, `purd`, `purples`, `rdpu`, `reds`,
2496
+ `ylgn`, `ylgnbu`, `ylorbr`, `ylorrd` (9 colors) and diverging `brbg`, `piyg`, `prgn`, `puor`,
2497
+ `rdbu`, `rdgy`, `rdylbu`, `rdylgn`, `spectral` (11 colors); Crameri's Scientific colour maps
2498
+ 8 (MIT; Crameri, Shephard and Heron 2020): sequential `batlow`, `batlowk`, `batloww`,
2499
+ `devon`, `lajolla`, `bamako`, `davos`, `bilbao`, `nuuk`, `oslo`, `grayc`, `hawaii`, `lapaz`,
2500
+ `tokyo`, `buda`, `acton`, `turku`, `imola`, `glasgow`, `lipari`, `navia`, diverging `broc`,
2501
+ `cork`, `vik`, `lisbon`, `tofino`, `berlin`, `roma`, `bam`, `vanimo`, `managua`,
2502
+ multi-sequential `oleron`, `bukavu`, `fes` and cyclic `romao`, `bamo`, `broco`, `corko`,
2503
+ `viko` (256 colors each);
2504
+ `ggplot2` is ggplot2's continuous default (`#132B43` → `#56B1F7`). The
2505
+ `color_map` setting (alias `cmap`; inherited, default `"rainbow_llhh"`) is the gradient of
2506
+ heatmaps, contours and numbers given as colors. A `ColorMap` is a gradient over [0, 1]
2507
+ only: the values' limits and scale are their [color axis](#6-color-and-size-axes)'s, so
2508
+ series given one `ColorMap` object keep limits of their own; a shared color axis shares
2509
+ limits.
2510
+
2511
+ ### Size maps
2512
+
2513
+ ```python
2514
+ pl.SizeMap(sizes=(3, 13), by="area", under=None, over=None, bad=None)
2515
+ ```
2516
+
2517
+ `sizes` are the diameters at the limits of the [size axis](#6-color-and-size-axes).
2518
+ `by="area"` moves the area linearly between the end areas (with `sizes=(0, d)` and
2519
+ `size_limits="0/max"`, area is proportional to the value); `by="diameter"` moves the
2520
+ diameter. `under`/`over` default to the end sizes; `"none"` leaves those points out.
2521
+ `bad` (missing values) leaves them out by default. `size_map` also takes a pair of
2522
+ diameters.
2523
+
2524
+ ### Values in color and size
2525
+
2526
+ | Given to `color` (also `edge_color`, `marker_color`, `marker_edge_color`) | Meaning |
2527
+ |---|---|
2528
+ | a color string, `CMYK`, `Spot`, or a **tuple** of 3 or 4 numbers | one color |
2529
+ | a list of colors | one color per point |
2530
+ | a **list, array or other buffer of numbers** | one value per point, mapped through the color axis |
2531
+ | an `(n, 3)` or `(n, 4)` buffer | one color per point |
2532
+ | `"density"` or `pl.Density(…)` | the points' density, mapped through the color axis |
2533
+ | a dict `{category: number}` or `{category: color}` (box, bar, violin) | per category |
2534
+
2535
+ A tuple of numbers is always one color and a list of numbers is always values, so
2536
+ `color=[0.2, 0.4, 0.6]` with a point count other than 3 is an error (use a tuple for one
2537
+ RGB color). A `ColorMap` goes in `color_map`, not `color`. Values go through the series'
2538
+ color axis wherever a series maps them: points (Scatter, Strip, Swarm `color` and
2539
+ `edge_color`; the markers of Line, Errorbar, Stem and Regression), cells, categories (Box,
2540
+ Bar, Violin `color`). A box's outliers are computed, so its `marker_color` and
2541
+ `marker_edge_color` take colors only. A line's `color` and every `edge_color` of bars,
2542
+ boxes, violins, pies and hexagons are one color. Values elsewhere are errors that name the
2543
+ setting.
2544
+
2545
+ `size` takes a diameter (a length), diameters per point (px), or values per point mapped
2546
+ through the size axis when the series has a `size_map` or a `size_axis`; `"density"` is
2547
+ always mapped (default sizes `SizeMap()`). A `SizeMap` goes in `size_map`. `marker_size`
2548
+ (lines, error bars, stems, regressions, box outliers) is diameters in px only: those
2549
+ series have no size axis.
2550
+
2551
+ Aliases, on every class with the setting: `c` = `color`, `s` = `size`, `cmap` =
2552
+ `color_map`, `smap` = `size_map` (also in style keys). Giving both names is an error.
2553
+
2554
+ ### Point density
2555
+
2556
+ ```python
2557
+ p.scatter(x, y, c="density", draw_order="density") # densest points drawn last
2558
+ p.scatter(x, y, c=pl.Density(adjust=0.5, normalize="max"), cmap="magma")
2559
+ pl.Density(bandwidth="scott", adjust=1.0, normalize="pdf", method="auto", grid=512)
2560
+ ```
2561
+
2562
+ The 2-D Gaussian kernel density at each point of the series, as scipy's
2563
+ `gaussian_kde(np.array([x, y]))(np.array([x, y]))`: the kernel covariance is the data
2564
+ covariance times Scott's factor n^(-1/6) (`"silverman"`: Silverman's), or a number
2565
+ (isotropic standard deviation) or a 2 × 2 matrix; `adjust` multiplies it. It is computed
2566
+ on the axis positions (log axes in log space); NaN points get NaN. `normalize`: `"pdf"`
2567
+ (scipy's values), `"count"` (points per unit area) or `"max"` (0–1); colors are the same
2568
+ under automatic limits. `method`: `"exact"` (the sum over all points, multithreaded in
2569
+ C, equal to scipy's), `"grid"` (binned, blurred and read back, about 1e-4 relative) or
2570
+ `"auto"` (exact up to 20,000 points). A `Density` (or `"density"`) is accepted by
2571
+ `color`, `edge_color`, `size` (through the size axis, default `SizeMap()`), `alpha` (mapped
2572
+ linearly to `alpha_range`, default (0.2, 1)) and `draw_order`, and by `marker_color` and
2573
+ `marker_edge_color` of Line (one line), Errorbar, Stem and Regression; one object computes each
2574
+ series' own density, cached until a setting changes, and exposed as
2575
+ `series.stats["density"]`. The colorbar label defaults to `"density"`.
2576
+
2577
+ ### Drawing order
2578
+
2579
+ `draw_order` on scatter, strip and swarm: `None` (call order), `"density"` (ascending: the
2580
+ densest points are drawn last), `"-density"`, or sort keys per point (ascending; give
2581
+ `-z` for descending). Every per-point column (positions, colors, sizes, markers, opacities)
2582
+ is reordered together; the sort is stable and NaN keys come first. Setting `color` to a
2583
+ density does not reorder by itself.
2584
+
2585
+ ### Number formats
2586
+
2587
+ One format applies wherever a number becomes text: `tick_format` (plot and colorbar
2588
+ axes) and `value_label_format` (value labels of bars, histograms, heatmaps, contours and
2589
+ pies).
2590
+
2591
+ | Format | 1234.5, 0.05, −2 as one label set |
2592
+ |---|---|
2593
+ | `"auto"` (default) | `1234.50`, `0.05`, `-2.00`: the fewest equal decimals; on axes, a ×10ᵏ factor beyond `sci_limits`, elsewhere each label in scientific form |
2594
+ | a format string | `"{:.1f} ms"` → `1234.5 ms` (`str.format`, one field) |
2595
+ | a function | `value -> str` or `value -> rich content` |
2596
+ | `"percent"` | `123450%`, `5%`, `-200%` |
2597
+ | `"sci"` | `1.2345×10³`, `5.0000×10⁻²`, `-2.0000` (no ×10⁰) |
2598
+ | `"eng"` | `1.2345×10³`, `50.0000×10⁻³`, `-2.0000` (exponents multiples of 3) |
2599
+ | `"si"` | `1.2345k`, `50.0000m`, `-2.0000` (y … Y, µ for 10⁻⁶) |
2600
+ | `"int"` | `1235`, `0`, `-2` |
2601
+
2602
+ Every preset chooses the decimals for all labels together, so they line up (`1.0k`,
2603
+ `1.5k`, `2.0k`); halves round away from zero (`1234.5` → `1235`), and a value rounding
2604
+ to the next power is written in it (`9.96` at 2 digits → `10`). NaN gives an empty label.
2605
+ Format strings and functions get the raw value; separators, minus and affixes then apply
2606
+ to the numbers in their result (rich content is used as is).
2607
+
2608
+ Inherited settings (figure → plot → axis; series → its color axis):
2609
+
2610
+ | Setting | Default | Values |
2611
+ |---|---|---|
2612
+ | `decimal_separator` | `"."` | any string |
2613
+ | `thousands_separator` | `""` | any string (`","`, `"."`, `" "`; a thin space U+2009 needs an embedded font) |
2614
+ | `minus` | `"hyphen"` | `"hyphen"` (`-`, every font; exponents too) or `"minus"` (U+2212, taken from an installed font, which is then embedded) |
2615
+ | `prefix`, `suffix` | `""` | text around every number |
2616
+ | `precision` | unset | significant digits of `auto`, `sci`, `eng`, `si` (unset: as needed to tell the labels apart) |
2617
+
2618
+ ### Markers
2619
+
2620
+ | Name | Area of the unit shape |
2621
+ |---|---|
2622
+ | `circle` | π/4 |
2623
+ | `square` | 1 |
2624
+ | `diamond` | 0.5 |
2625
+ | `triangle_up`, `triangle_down`, `triangle_left`, `triangle_right` | √3/4 |
2626
+ | `plus` | 0.51 |
2627
+ | `cross` | 0.5754 |
2628
+
2629
+ Aliases: `triangle`, `o`, `s`, `d`, `^`, `v`, `<`, `>`, `+`, `x`. A `vec_io.Path` or SVG
2630
+ path data in a unit box centred on the origin also works. `pl.register_marker(name, path)`
2631
+ adds a shape (its area measured from the outline); `plot_io.markers.marker_path(name)` returns a path
2632
+ for vec_io's `draw_markers`; `plot_io.markers.marker_area(name)` its area.
2633
+
2634
+ ## 8. Output
2635
+
2636
+ ```python
2637
+ fig.save(path, **options) # .pdf, .eps, .png, .jpg/.jpeg, .jxl, .avif
2638
+ fig.to_bytes(format="pdf", **options)
2639
+ fig.draw(canvas, x=0, y=0) # on any vec_io canvas (its document's fonts); returns (width, height) in px
2640
+ fig.size() # (width, height) in px
2641
+ p.save(path, …) p.to_bytes(…) p.draw(canvas, …) # one plot alone, at its size in the figure
2642
+ ```
2643
+
2644
+ The figure is drawn once on a page of a vec_io document in px; each output is made from
2645
+ it with its own options:
2646
+
2647
+ | Options | Of |
2648
+ |---|---|
2649
+ | `title`, `author`, `subject`, `keywords`, `creator`, `creation_date`, `pdf_a`, `color_mode`, `ink_limit`, `icc_profile`, `base_dir` | the document (vec_io `Document`) |
2650
+ | `font_dirs`, `system_fonts` | the fonts text is shaped and embedded with ([fonts](#1-conventions)) |
2651
+ | `text_as_paths` | text drawn as the outlines of its glyphs: no font embedded, text not selectable (default `False`) |
2652
+ | `quality` | the figure's `quality` when not given: 1–100, `"lossless"` (not JPEG) or `"auto"`, the default: PNG 90, a palette of at most 256 colors; JPEG 90; JPEG XL, AVIF and rasterized content in a PDF lossless |
2653
+ | `compression` | `"fast"`, `"balanced"` (default), `"best"`: the encoder's effort (PDF streams and images, PNG, JPEG, JPEG XL, AVIF) |
2654
+ | `simplify` | the output's `simplify` for content without its own (series have theirs, below) |
2655
+ | `compress`, `font_hinting` | PDF and EPS: compressed streams (default) or a readable file; TrueType hinting kept in embedded subsets (default: left out) |
2656
+ | `flatten_transparency`, `flatten_fallback`, `flatten_dpi`, `flatten_budget`, `flatten_cell` | PDF: translucent content drawn as opaque vectors (default off), and what cannot be (vec_io's transparency flattening: an image by default); EPS: always flattened, the others tune it |
2657
+ | `dpi`, `background` | images: resolution (default 384: four image pixels per px); a color under the figure (default the figure's, white; `None` is transparent, white in JPEG) |
2658
+
2659
+ EPS output (`.eps`) is vec_io's: one page of PostScript Level 3, its transparency (the
2660
+ `alpha` of bands, markers, …) flattened into opaque shapes, with an image where it cannot
2661
+ be (dense translucent scatters), and its fonts embedded (Type 42 or CFF). JPEG XL output
2662
+ (`.jxl`) needs libjxl, AVIF output (`.avif`) libavif 1.x. Images inside a
2663
+ PDF (rasterized series, heatmaps) are stored losslessly or as JPEG (`quality`), never as
2664
+ JPEG XL, so every PDF reader shows them. Fonts are embedded subsets without hinting: a
2665
+ typical figure's text adds a few KB per face. A plot
2666
+ saved alone keeps its size in the figure (axes or box, by `align`), its limits and ticks
2667
+ (those of its shared axes too), its title, legend and attached colorbars, and shows its
2668
+ outer tick labels ([layout](#layout)).
2669
+
2670
+ PNG quality: by default (`quality="auto"`) PNGs are palette images at quality 90: the plot's
2671
+ own colors stay exact, only antialiasing and gradients are approximated, and an image 256
2672
+ colors cannot render well enough stays lossless. The 21 example PNGs total 0.74 MB this way,
2673
+ 1.57 MB with `quality="lossless"` and 1.38 MB lossless with `compression="best"` (same pixels,
2674
+ slower). Notebook previews are lossless.
2675
+
2676
+ ### Large data
2677
+
2678
+ * Series map their data to page coordinates in C (`kernels.scaled`) and draw with
2679
+ one bulk vec_io call (markers, lines, areas, segments).
2680
+ * `simplify` (series, plot or figure; default `"auto"`) goes to each of the series' vec_io
2681
+ calls, and vec_io applies it per output. PDF: `"auto"` decimates lines with many points
2682
+ per pixel column and culls markers that later markers hide when that pays off (vec_io
2683
+ decides per call from the data); `True` or a dpi always simplifies at that resolution;
2684
+ `False` never. PNG, JPEG, JPEG XL and AVIF draw everything (rasterizing hidden content
2685
+ costs less than culling it, and the pixels are the same) and decimate lines for their
2686
+ resolution, unless `False`.
2687
+ * `rasterize=True` or a dpi draws the series in a vec_io group the PDF holds as an image;
2688
+ axes and text stay vectors. Image output draws the group as vectors at its own
2689
+ resolution.
2690
+
2691
+ Timings (`tools/bench.py`, 8 threads, PDF written):
2692
+
2693
+ | Case | Time |
2694
+ |---|---|
2695
+ | `import plot_io` (vec_io included) | 0.06 s |
2696
+ | empty figure, 4 plots with ticks and labels | 0.005 s |
2697
+ | scatter, 100k points, one color | 0.02 s |
2698
+ | scatter, 1M points, colors from a `ColorMap` | 0.25 s |
2699
+ | scatter, 1M points, `c=values`, PDF / PNG at 150 dpi | 0.56 s / 0.43 s |
2700
+ | line, 1M points (`simplify=False` / `True`) | 0.08 s / 0.03 s |
2701
+ | box plots, 10 categories × 1M values | 0.09 s |
2702
+ | heatmap 1000 × 1000 (`image`) with a colorbar | 0.06 s |
2703
+ | heatmap 200 × 200, uneven cells (`cells`) | 0.04 s |
2704
+ | scatter, 1M points, `rasterize=300` | 0.22 s |
2705
+ | `simplify="auto"` on 1M points it does not cull: overhead | < 0.01 s |
2706
+
2707
+ ## 9. Genome tracks
2708
+
2709
+ ```python
2710
+ fig = pl.Tracks("chr2:143,120,001-143,780,000", width="5in")
2711
+ fig.hic(gwseq_io.open("cells.hic"), y_axis={"label": "Hi-C"}, depth=500_000)
2712
+ fig.gtf(gwseq_io.open("gencode.gtf.gz"), gene_type="protein_coding")
2713
+ fig.bed(gwseq_io.open_peaks("sites.tsv"), y_axis={"label": "Sites"})
2714
+ sets = fig.track(stacked=True) # one track, a named row per file
2715
+ for c in ("con", "pio"):
2716
+ sets.bed(gwseq_io.open_peaks(f"{c}.tsv"), name=c)
2717
+ p = fig.track(y_axis={"label": "A/B"}) # an empty track: series overlaid
2718
+ before = p.bigwig(gwseq_io.open("before.bw"), name="before", color="sky", fill_to=False)
2719
+ p.bigwig(gwseq_io.open("after.bw"), name="after", color="rose", fill_to=before)
2720
+ fig.bigwig(gwseq_io.open("atac.bw"), y_axis={"label": "ATAC"})
2721
+ fig.vline(143_400_000) # through every track and the gaps
2722
+ fig.save("locus.pdf")
2723
+ fig.save("other.pdf", region=("chr2", 80_000_000, 81_000_000))
2724
+ ```
2725
+
2726
+ Genome tracks are made of general pieces:
2727
+
2728
+ * **A tracks figure.** `pl.Tracks(region, **settings)` is a `Figure` with
2729
+ `layout="tracks"` ([§2](#arrangement)): one column of plots, top to bottom in creation
2730
+ order, sharing x (`share_x="all"`, tick labels and the axis title under the bottom plot
2731
+ only), `spacing` 0, `width` 480 px. Its `region`, `unit`, `unit_in` and `origin` go to
2732
+ `fig.x_axis`, the settings of every plot's x axis ([figure axes](#figure-axes)), with
2733
+ `scale="genome"`; the other keywords are the figure's.
2734
+ * **Tracks.** A `Track` is a plot preset: a `height` from its content, `space_above` it,
2735
+ axis lines left and bottom (Hi-C: bottom only), at most 4 y ticks and the y axis'
2736
+ `label` in the row band (`label_position="band"`, `label_pad="0.5em"`). `fig.track(**settings)`
2737
+ returns an empty one; a plot type called on the figure (`fig.bigwig`, `fig.bed`,
2738
+ `fig.genes`, `fig.gtf`, `fig.hic`, also `fig.line`, …) adds a track holding it and returns
2739
+ the series (`.plot` is the track; the track's settings, `title`, `x_axis` and `y_axis`
2740
+ go to it, and
2741
+ `name` names the series, its legend entry, as everywhere). Called on a track
2742
+ (`p.bigwig(…)`, `p.line(…)`, `p.hline(…)`), plot types overlay in it.
2743
+ * **The genome scale.** An x axis with `scale="genome"` is linear in bp: its limits are its
2744
+ `region` (less its `origin`), without padding, its tick labels in bp, kb or Mb, its
2745
+ automatic label the chromosome (`chr2 (Mb)`). A genome series asks its x axis for it
2746
+ when the axis has no scale of its own, so the genome series work on any plot too
2747
+ (`pl.Plot().bigwig(reader, region=…)`: the series' own `region`).
2748
+ * **Genome layers.** `bigwig`, `bed`, `genes`, `gtf` and `hic` are plot types like the
2749
+ others, drawn with the shared geoms: a signal's bins as a step line, a band and bars;
2750
+ intervals and gene models as rectangles, lines and names; contacts as a grid of cells
2751
+ under a 45° transform.
2752
+ * **Row labels, groups, lines through rows** are figure features ([§2](#rows)):
2753
+ the y axis' `label` is a row label lined up across the tracks, `fig.group(first, last, label=…,
2754
+ letter=…)` labels consecutive tracks (with x tick labels under the last one), and
2755
+ `fig.vline(x, rows=…)`, `fig.vspan(x0, x1, rows=…)` run through the tracks and the gaps.
2756
+
2757
+ Details:
2758
+
2759
+ * **Region.** `region` is a string, 1-based and inclusive
2760
+ (`"chr2:143,120,001-143,780,000"`; positions may carry a unit: `"chr1:1.2M-1.5M"`,
2761
+ `"chr1:500kb-2Mb"`, with `k`, `M`, `G` and an optional `b`, any case, and `,` or `_`
2762
+ between thousands), a `(chr, start, end)` tuple or list (0-based, half-open; the same
2763
+ position strings), or a mapping with `chr`, `start` and `end`; `plot_io.genome.parse_region` gives the
2764
+ `Region` (`chr`, `start`, `end`). A series reads its own `region`, else its x axis'.
2765
+ Data are read when the figure is drawn, for the region drawn: `save`, `to_bytes`, `draw`
2766
+ and `size` take `region=` to draw another one (it replaces `fig.x_axis`'s region for
2767
+ that call).
2768
+ * **x axis.** Ticks under every track (but a Hi-C triangle with `direction="down"`), tick
2769
+ labels and the axis label (`chr2 (Mb)`) under the bottom track; a group's last track has
2770
+ tick labels too; `fig.set(label_outer=False)` labels every track. `unit` (`auto`, `bp`,
2771
+ `kb`, `Mb`) and `unit_in` (`"label"`: `chr2 (Mb)` under `143.2 143.3 …`; `"ticks"`:
2772
+ `-500kb 0 500kb`) set the labels; `tick_format="chr:pos"` writes positions
2773
+ (`chr2:143,250,000`, in bp with `,` between thousands unless `unit` is set:
2774
+ `chr2:143.25Mb`), the position itself even with an `origin`, and leaves the automatic
2775
+ label out; `fig.x_axis(label=…)` replaces the label, and in a
2776
+ string `{chr}`, `{unit}`, `{start}`, `{end}` are filled in (`""`: none). `origin` (a
2777
+ position, `"center"`, `"start"` or `"end"` of the region) is drawn at 0: every series on
2778
+ the axis is drawn less it ([transforms](#5-series)), and limits, ticks and decorations
2779
+ are distances from it (`fig.vline(0)`, `fig.vspan(-1000, 1000)`); a region given to
2780
+ `fig.vspan` is in positions.
2781
+ * **y axis.** An interval track's y axis has a tick per named series (`fig.bed(…,
2782
+ name=…)`; each `name` of a `stacked` track) at the middle of its rows, the name as its
2783
+ label; without names, and on Hi-C tracks, the y axis is hidden (`y_axis(visible=True)`
2784
+ shows it).
2785
+ * **Heights.** A track's `height`: a length, a share (`"1fr"`, of the room the fixed heights
2786
+ leave in a figure of given height, `reference="figure"`), or `auto`: the Hi-C triangle's
2787
+ height (square cells; `max_height`, a length or a percentage of the width such as
2788
+ `"33%"`, caps it, and `fit` clips the distances above or squashes the triangle), the rows
2789
+ of intervals × `row_height` plus the y axis padding above and below, or `auto_height`
2790
+ for signals. The figure height follows. `space_above` is the space above a track:
2791
+ `auto_space_above` above every track but the first.
2792
+ * **Stacked intervals.** A track with `stacked=True` puts each interval series on rows of
2793
+ its own, top to bottom, named left of its rows; they take no legend entries.
2794
+ * **Bins.** `bins` of `bigwig` and `hic`: a width on the axes (`"0.5px"`, the default: two
2795
+ bins per px of the axes width; Hi-C: the finest resolution whose cells are at least that
2796
+ wide), a size (`"10kb"`, `"5000bp"`, `"5000d"`), or a count (`200`). A size is read on
2797
+ the genome-wide grid of that size: the region grows outward to it
2798
+ (`snap_to_grid="expand"`), and the first and last bins are then cut to the region. A
2799
+ count cuts the region itself into that many bins. The bins (and Hi-C `height="auto"`, interval rows) follow the axes width the
2800
+ layout places: with the default `reference="axes"` it is `width`, so each file is read
2801
+ once per draw; with `reference="plot"` or `"figure"`, the data are read again for the
2802
+ width the first round places (reads are cached by their bins).
2803
+ * **Shared y.** `share_y=other_track` on a track, or `fig.set(share_y="bigwig")` to put
2804
+ every track with a `bigwig` series on one scale (a figure's `share_x`/`share_y` takes a
2805
+ plot type's name).
2806
+
2807
+ ### Readers
2808
+
2809
+ plot_io does not import gwseq_io: it reads any object with the methods of gwseq_io's
2810
+ readers, recognised by their `type` attribute (`"bigwig"`, `"bigbed"`, `"bed"`, `"peaks"`,
2811
+ `"gtf"`, `"gff3"`, `"hic"`), else by their methods. The calls, which another reader can implement:
2812
+
2813
+ | Data | Methods called |
2814
+ |---|---|
2815
+ | signal (bigWig; the coverage of bigBed, BED and peaks readers) | `read_values([(chr, start, end)], bin_count=n, bin_mode=…, def_value=…, zoom="auto")`, or with `bin_size=b, snap_to_grid="expand"` and the row's bounds from `resolve_regions([(chr, start, end)], bin_size=b, snap_to_grid="expand")` (without it, `snap_to_grid=False, full_bin=True`): one row of values |
2816
+ | intervals (bigBed, BED, peaks) | `read_entries([(chr, start, end)], columns=…)`: a table, a dict of columns; `columns` from `auto_sql` when the reader has it |
2817
+ | annotation (GTF, GFF3) | `read_entries([(chr, start, end)], model="transcript", gene_type=…, transcript_type=…)`: a table of transcripts: `start`, `end`, `strand`, `transcript_id`, `transcript_name`, `gene_id`, `gene_name`, `cds_start`, `cds_end` (−1 when non-coding); their exons are the table `nested["exons"]` (`start`, `end`), transcript `i`'s at rows `groups[i]:groups[i + 1]`. A reader is told for one by its `tss` method |
2818
+ | contacts (Hi-C) | `bin_sizes`, `normalizations`, `read_values((chr, start, end), bin_size=b, snap_to_grid="expand", normalization=…, matrix_type=…, max_distance=…)` (or `bin_count=n` instead of the first two): a square matrix; bounds from `resolve_regions((chr, start, end), bin_size=b, snap_to_grid="expand")["rows"]` |
2819
+
2820
+ Results are read as buffers (numpy arrays included) without importing numpy. A path
2821
+ instead of a reader raises `TypeError` (open it with `gwseq_io.open`, or
2822
+ `gwseq_io.open_peaks` for a TSV of locations), as do BAM and CRAM readers (pile the reads
2823
+ up into a bigWig first). A reader's error is raised with the track's label in the
2824
+ message.
2825
+
2826
+ ### BigWig
2827
+
2828
+ ```python
2829
+ pl.BigWig(reader=None, plot=None, *, x=None, y=None, **settings)
2830
+ ```
2831
+
2832
+ A step line along the bins, filled to `fill_to`. `reader` is a signal reader, a function
2833
+ `f(chr, start, end, bins)` returning the values, or `None` with `y` (values evenly over
2834
+ the region) and optionally `x` (bin centres, or n + 1 edges, in bp). The color is black
2835
+ when the series is alone in its track, palette colors when overlaid. `fill_to=<series>`
2836
+ fills between two signals, each part in the fill color of the series on top. For more,
2837
+ the track's `fill_mode` fills between all its signals, in place of their `fill_to`:
2838
+ `"in_between(up)"` (or `"in_between"`) fills each band between two neighbouring signals
2839
+ in the color of the one just above, `"in_between(down)"` of the one just below;
2840
+ `"in_between(max)"` fills from the lowest signal to the highest in the color of the top
2841
+ one, `"in_between(min)"` of the bottom one. The colors follow wherever the order changes
2842
+ (lines get points where they cross), and 0 is not kept on the y axis:
2843
+
2844
+ ```python
2845
+ t = fig.track(y_axis={"label": "Lamin A/C"}, fill_mode="in_between(up)")
2846
+ t.bigwig(neo_reader, name="Neo", color="sky")
2847
+ t.bigwig(pax7_reader, name="Pax7", color="rose")
2848
+ ```
2849
+
2850
+ <!-- settings:BigWig -->
2851
+ | Setting | Default | Meaning |
2852
+ |---|---|---|
2853
+ | `region` | — | The region read: `"chr2:143,120,001-143,780,000"` (1-based, inclusive), `(chr, start, end)` (0-based, half-open) or a mapping; unset: the x axis' `region`. |
2854
+ | `bins` | '0.5px' | A bin count over the region (exactly, not on a grid); a bin size (`"10kb"`, `"5000bp"`), read on the genome-wide grid of the size (the row grown to it, then cut to the region); or a bin width on the axes (`"0.5px"`: two bins per px, read as a count). |
2855
+ | `bin_mode` | 'mean' | Reduction per bin: `mean`, `max` (keeps narrow peaks), `min`, `sum`, … (gwseq_io's). |
2856
+ | `def_value` | 0.0 | Value of bases no record covers; NaN breaks the line there. |
2857
+ | `kind` | 'step' | `step` (a step line along the bins), `line` (through the bin centres) or `bar` (one rectangle per bin). |
2858
+ | `fill_to` | 0.0 | Fill between the signal and a value, another series of the track (colored by whichever is above), or `False`. |
2859
+ | `fill` | 0.2 | Fill (to `fill_to`): an opacity of the line color, `True` (opaque), a color, or `False`. |
2860
+ | `color` | — | Line color; default black alone in its track, the next palette color when overlaid. |
2861
+ | `transform` | — | A function applied to each value (log, scaling). |
2862
+ | `name` | — | Legend entry; unset: not in the legend. |
2863
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
2864
+ | `z` | — | Drawing order (higher on top); default: call order. |
2865
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
2866
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
2867
+ | `line_width` | inherited (0.5) | Line width. Length. |
2868
+ | `text_color` | inherited ('black') | Text color. |
2869
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
2870
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
2871
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
2872
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
2873
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
2874
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
2875
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
2876
+
2877
+ Groups: `FillStyle`, `Font`.
2878
+ <!-- /settings -->
2879
+
2880
+ ### Bed and Genes
2881
+
2882
+ ```python
2883
+ pl.Bed(reader, plot=None, **settings)
2884
+ pl.Genes(reader, plot=None, **settings) # Bed with kind="genes", rows expanded, names on,
2885
+ # filled solid without outlines
2886
+ ```
2887
+
2888
+ `reader` is an interval reader, or the columns themselves: a dict, a DataFrame, or rows
2889
+ (dicts, or tuples in BED order). Used columns: `chr` (when given, rows of other
2890
+ chromosomes are left out), `start`, `end`, `name`, `score`, `strand`, `thickStart`,
2891
+ `thickEnd`, `itemRgb` (`reserved` in bigBeds), `blockCount`, `blockSizes`, `blockStarts`.
2892
+ `genes` draws each BED12 model as a line, thin boxes for UTRs and thick boxes for coding
2893
+ exons, chevrons on introns (`strand`), and its name in italics with a strand mark
2894
+ (`Pcsk2 ›`). Names go left of their feature and are dropped where they would collide;
2895
+ with `rows="expand"` packing leaves room for them (`names=False`: none). `name_region` names only the
2896
+ features overlapping it (a locus within a wider view), and packing then makes room only
2897
+ for those names. Features are outlined in their color (`outline`, `line_width`) over their
2898
+ `fill` (an opacity of their color, 0.3; `False` for outlines only), the outline inside the feature's extent: a
2899
+ feature narrower than two borders is one line, `line_width` wide. `recolor` snaps the features' colors
2900
+ (`itemRgb` ones included) to the named colors (`"blue 0.4"`, §7): `True` takes the
2901
+ closest of all shades, a level such as `0.4` the closest color's shade at that level, so
2902
+ every feature has the same lightness.
2903
+
2904
+ <!-- settings:Bed -->
2905
+ | Setting | Default | Meaning |
2906
+ |---|---|---|
2907
+ | `region` | — | The region read: `"chr2:143,120,001-143,780,000"` (1-based, inclusive), `(chr, start, end)` (0-based, half-open) or a mapping; unset: the x axis' `region`. |
2908
+ | `kind` | 'boxes' | `boxes` (intervals, 8/13.2 of a row high: 8 px in the default row) or `genes` (BED12 models: exons as high, UTRs half, introns). |
2909
+ | `rows` | 'collapse' | `collapse`: one row; `expand`: overlapping features (and their labels) packed onto rows. |
2910
+ | `min_width` | 0.75 | Narrowest drawn feature (1-bp sites stay visible). Length. |
2911
+ | `color` | 'black' | A color, `"item_rgb"` (the `itemRgb` column) or `"score"` (the `score` column through `color_map`). |
2912
+ | `recolor` | False | Replace each feature's color by the closest named color (`True`: the closest shade; a level 0–1: the closest color's shade at that level); `False`: as given. Not with `color="score"`. |
2913
+ | `names` | False | Feature names (`name`) left of the features, dropped where they collide. |
2914
+ | `name_region` | — | Only features overlapping this region (as `region` takes it) get names; `None`: all. |
2915
+ | `strand` | False | Strand chevrons on boxes and introns. |
2916
+ | `outline` | True | Outline features in their color (`line_width` wide). |
2917
+ | `fill` | 0.3 | Fill of the features: an opacity of their color (times `alpha`), `True` (opaque), a color, or `False` (outlines only). |
2918
+ | `row_height` | '1.2em' | Height of a row; the track's automatic height is rows × it, plus the y axis padding. Length; `%`: of the font size. |
2919
+ | `name_font_size` | '0.85em' | Font size of feature names. Length; `%`: of the font size. |
2920
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
2921
+ | `color_limits` | — | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
2922
+ | `color_scale` | — | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
2923
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
2924
+ | `name` | — | Legend entry; unset: not in the legend. |
2925
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
2926
+ | `z` | — | Drawing order (higher on top); default: call order. |
2927
+ | `line_width` | inherited (0.5) | Line width. Length. |
2928
+ | `text_color` | inherited ('black') | Text color. |
2929
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
2930
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
2931
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
2932
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
2933
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
2934
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
2935
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
2936
+
2937
+ Groups: `FillStyle`, `TextStyle` (`name_`), `Font`.
2938
+ <!-- /settings -->
2939
+
2940
+ `Genes` (only its own defaults):
2941
+
2942
+ <!-- settings:Genes -->
2943
+ | Setting | Default | Meaning |
2944
+ |---|---|---|
2945
+ | `kind` | 'genes' | `boxes` (intervals, 8/13.2 of a row high: 8 px in the default row) or `genes` (BED12 models: exons as high, UTRs half, introns). |
2946
+ | `rows` | 'expand' | `collapse`: one row; `expand`: overlapping features (and their labels) packed onto rows. |
2947
+ | `names` | True | Feature names (`name`) left of the features, dropped where they collide. |
2948
+ | `strand` | True | Strand chevrons on boxes and introns. |
2949
+ | `outline` | False | Outline features in their color (`line_width` wide). |
2950
+ | `fill` | True | Fill of the features: an opacity of their color (times `alpha`), `True` (opaque), a color, or `False` (outlines only). |
2951
+
2952
+ Groups: `FillStyle`.
2953
+ <!-- /settings -->
2954
+
2955
+ ### Gtf
2956
+
2957
+ ```python
2958
+ pl.Gtf(reader, plot=None, **settings) # Genes from a GTF or GFF3 reader
2959
+ ```
2960
+
2961
+ `reader` is a GTF or GFF3 reader (`gwseq_io.open("gencode.gtf.gz")`, bgzipped and indexed;
2962
+ `gwseq_io.index_gtf` makes one from any GTF), or BED12 columns as `Genes` takes them. The
2963
+ transcripts overlapping the region come whole, with their exons outside it. With
2964
+ `model="gene"` each gene is one model: its transcripts' exons merged, coding from the
2965
+ first CDS start to the last CDS end (the stop codon included), named by `gene_name`;
2966
+ `model="transcript"` draws every transcript, named by `transcript_name`. An id names what
2967
+ has no name. `gene_type` and `transcript_type` keep those biotypes. A `Bed` or `Genes`
2968
+ given a GTF reader raises `TypeError` pointing here.
2969
+
2970
+ `Gtf` (only its own settings and defaults):
2971
+
2972
+ <!-- settings:Gtf -->
2973
+ | Setting | Default | Meaning |
2974
+ |---|---|---|
2975
+ | `model` | 'gene' | `gene`: one model per gene, its transcripts' exons merged and coding from the first CDS start to the last CDS end, named by `gene_name`; `transcript`: one per transcript, named by `transcript_name` (ids where there is no name). |
2976
+ | `gene_type` | — | Gene biotypes kept (`"protein_coding"`, a list); `None`: all. |
2977
+ | `transcript_type` | — | Transcript biotypes kept; `None`: all. |
2978
+ <!-- /settings -->
2979
+
2980
+ ### HiC
2981
+
2982
+ ```python
2983
+ pl.HiC(reader, plot=None, **settings)
2984
+ ```
2985
+
2986
+ The upper triangle of the contact matrix, the diagonal on the x axis, each cell a
2987
+ diamond: the matrix is drawn as an image under a 45° transform and clipped to the track.
2988
+ `reader` is a Hi-C reader, or a square matrix over the region. `bins="0.5px"` (the
2989
+ default) takes the finest of the reader's `bin_sizes` whose cells are at least 0.5 px wide;
2990
+ the cells of a size (`bins="5kb"`) sit on the file's grid, those past the region cut by
2991
+ the track's edges, and `bins=n` reads n cells over the region exactly. Its color axis' limits default
2992
+ to quantiles of the cells drawn (`color_limits="q:0.01/q:0.99"`), on a log scale
2993
+ (`color_scale="log"`; cells of 0 take the map's low end; cells without a value take
2994
+ `nan_color`, transparent), through the figure's `color_map`.
2995
+
2996
+ <!-- settings:HiC -->
2997
+ | Setting | Default | Meaning |
2998
+ |---|---|---|
2999
+ | `region` | — | The region read: `"chr2:143,120,001-143,780,000"` (1-based, inclusive), `(chr, start, end)` (0-based, half-open) or a mapping; unset: the x axis' `region`. |
3000
+ | `depth` | — | Largest distance shown (bp); default the region's span (the whole triangle). |
3001
+ | `bins` | '0.5px' | A bin count over the region (exactly, from the coarsest resolution giving that many); one of the reader's `bin_sizes` (`"10kb"`), read on its grid (the region grown to it, then cut by the track); or a cell width on the axes (`"0.5px"`): the finest resolution whose cells are at least that wide. |
3002
+ | `normalization` | 'none' | `"none"` or one of the reader's `normalizations`. |
3003
+ | `matrix_type` | 'observed' | `observed`, `oe` (observed / expected) or `expected`. |
3004
+ | `color_map` | inherited ('rainbow_llhh') | The gradient numbers given as colors are drawn with: a `ColorMap`, a map name or colors (alias `cmap`); default: the style's. |
3005
+ | `color_limits` | 'q:0.01/q:0.99' | Limits of the series' color axis, as an axis' `limits`: `"-2/2"`, `"0/max"`, `"q:0.01/q:0.99"`; unset: `"auto"`, the values' range. |
3006
+ | `color_scale` | 'log' | Scale of the series' color axis (`log`, `sqrt`, …); unset: `linear`. |
3007
+ | `color_axis` | — | A shared `ColorAxis` (`figure.color_axis(…)`) in place of the series' own: it holds the map, limits and scale. |
3008
+ | `nan_color` | — | Color of cells without a value; default: the map's `bad` (transparent). |
3009
+ | `direction` | 'up' | `up`: the apex up; `down`: the triangle hangs from the top. |
3010
+ | `max_height` | — | Largest height of the track: a percentage of its width (`"33%"`) or a length; `None`: the triangle's (square cells). |
3011
+ | `fit` | 'clip' | How the triangle fits a height below its own (`max_height`, or the track's `height`): `clip` keeps square cells and cuts the distances above; `squash` flattens the whole triangle. |
3012
+ | `colorbar` | False | Attach a colorbar to the track. |
3013
+ | `name` | — | Legend entry; unset: not in the legend. |
3014
+ | `alpha` | inherited (1.0) | Opacity, multiplying the colors' own. |
3015
+ | `z` | — | Drawing order (higher on top); default: call order. |
3016
+ | `rasterize` | inherited (False) | `True` or a dpi: drawn as an image inside the PDF. |
3017
+ | `simplify` | inherited ('auto') | `"auto"`, `True`, a dpi or `False`: vec_io's `simplify`. |
3018
+ | `text_color` | inherited ('black') | Text color. |
3019
+ | `font_size` | inherited (11.0) | Base font size. Length; `%`: of the parent's font size. |
3020
+ | `font_family` | inherited ('Helvetica, Nimbus Sans, Arial, Liberation Sans, Arimo') | Font family. |
3021
+ | `font_stretch` | inherited ('normal') | Font width: `normal`, `condensed`, …, or a percentage (`"87.5%"`); the `wdth` axis of variable fonts. |
3022
+ | `font_variations` | inherited (None) | Variable font axes: `{"GRAD": 50}` or `'"GRAD" 50, "wght" 650'`. |
3023
+ | `font_optical_sizing` | inherited ('auto') | `auto`: a variable font's `opsz` axis follows the font size; `none`. |
3024
+ | `line_height` | inherited (1.0) | Height of a line of text: a multiple of the font size (`1.2`), a percentage of it, or `normal` (the font's ascent and descent). Text boxes and the gaps around them follow it, with the glyphs centered. |
3025
+ | `markup` | inherited (True) | Read markup in strings (`<b>`, `<i>`, `<sup>`, …: see [conventions](#1-conventions)); `False`: strings stay literal. |
3026
+
3027
+ Groups: `Font`.
3028
+ <!-- /settings -->
3029
+
3030
+ ### Tracks
3031
+
3032
+ `pl.Tracks(region=None, **settings)` returns the figure; `Track` has the settings of `Plot`,
3033
+ these added or with other defaults:
3034
+
3035
+ <!-- settings:Track -->
3036
+ | Setting | Default | Meaning |
3037
+ |---|---|---|
3038
+ | `space_above` | 'auto' | Space above the track; `auto`: none for the first track, else `auto_space_above`. Length; `%`: of the font size. |
3039
+ | `height` | 'auto' | Height of the track's axes: a length, a share of the room the fixed heights leave (`"1fr"`, with the figure's height given), or `auto`: Hi-C from its `depth` (square cells), intervals rows × `row_height`, else `auto_height`. |
3040
+ | `auto_height` | '4.5em' | Height of signal and empty tracks with `height="auto"`. Length; `%`: of the font size. |
3041
+ | `auto_space_above` | '0.6em' | The space `space_above="auto"` leaves. Length; `%`: of the font size. |
3042
+ | `stacked` | False | Interval series on rows of their own, top to bottom, each named left of its rows by its `name`. |
3043
+ | `fill_mode` | — | Fill between the track's signals (replacing their `fill_to`): `"in_between(up)"` (or `"in_between"`), each band between two neighbouring signals in the fill color of the one above; `(down)`, of the one below; `(max)`, one band from the lowest signal to the highest in the color of the top one; `(min)`, of the bottom one. `None`: each signal's `fill_to`. |
3044
+ <!-- /settings -->
3045
+
3046
+ ## 10. Styles
3047
+
3048
+ A style presets settings: `Figure(style=…)` (also accepted by `pl.Plot` and the series
3049
+ classes, which pass it to their figure). Explicit settings always win over the style.
3050
+
3051
+ ```python
3052
+ fig = pl.Figure(style="default")
3053
+ fig = pl.Figure(style={"base": "default", "font_size": 9, "Axis.grid": True})
3054
+ fig = pl.Figure(style={"base": ["house", "talk"], "palette": ["#333", "#c00"]})
3055
+
3056
+ pl.register_style("house", {"font_family": "Helvetica", "Legend.frame": True})
3057
+ pl.set_style("house") # figures created afterwards
3058
+ with pl.use_style({"font_size": 10}): # figures created inside the block
3059
+ ...
3060
+ pl.styles.names() # registered names
3061
+ pl.styles.settings("house") # the resolved dict (base theme included)
3062
+ ```
3063
+
3064
+ * **Keys.** Names of inherited settings (`"font_size"`, `"palette"`), `"Class.name"` for
3065
+ any setting of a class and its subclasses (`Figure`, `FigureTitle`, `MainTitle`, `Plot`, `Title`,
3066
+ `Legend`, `FigureLegend`, `Axis` (plot, color and size axes), `Colorbar`,
3067
+ `FigureColorbar`, every series class, `Series` for all of them, every decoration class,
3068
+ `Decoration` for all of them, `FigureVLine`, `FigureVSpan`, `FigureGroup`, the genome
3069
+ classes),
3070
+ or `"Group.member"` for every embedding of a group member (`"Marker.size"`,
3071
+ `"Stroke.line_width"`, `"TextStyle.font_weight"`).
3072
+ `"Colorbar.<axis setting>"` (`"Colorbar.tick_direction"`, `"Colorbar.tick_color"`, …)
3073
+ applies to color axes (the colorbars' axes) only, and `"XAxis.<setting>"`, `"YAxis.<setting>"` to the x or
3074
+ y axis of plots only; each wins over `"Axis.<setting>"` there.
3075
+ Keys starting with `--` are custom variables (`"--accent": "#c00"`), read by
3076
+ `var(--accent)`. Values are checked when the style is registered or set.
3077
+ * **`"base"`.** A style name or a list of names, applied left to right (later ones win);
3078
+ the dict's own keys are applied over them. Registered styles use the same form.
3079
+ * **Resolution.** The cascade of [conventions](#1-conventions): the object's own value,
3080
+ class rules, `"Class.name"` keys along the class hierarchy, the parent (inherited
3081
+ settings), `"Group.member"` keys, the class and group defaults, then the bare name. The
3082
+ effective theme is the inherited defaults (the bare names of `DEFAULTS`) with the
3083
+ expanded style merged over it.
3084
+ * **Default.** Without `style`, a figure takes the session style current when it is
3085
+ created (`use_style` innermost, else `set_style`), else `"default"`, which adds nothing
3086
+ to `DEFAULTS`.
3087
+ * **`scaling`.** A figure setting (default 1, or `"Figure.scaling"` in the style) that
3088
+ multiplies every absolute length: font sizes, line widths, marker sizes, tick lengths,
3089
+ pads and gaps, from the defaults, the style or set on objects (not the figure size).
3090
+ Lengths in `em` follow the scaled font size.
3091
+
3092
+ Bundled styles (`pl.styles.names()`), each the defaults of a library expressed in these
3093
+ settings (colors, fonts, grid, axis lines, ticks, legend and title placement, palette,
3094
+ color map, default series looks). They never change plot sizes or the minus sign
3095
+ (`style={"base": "matplotlib", "minus": "minus"}` gets matplotlib's).
3096
+
3097
+ | Style | Follows | Variants |
3098
+ |---|---|---|
3099
+ | `default` | `DEFAULTS` | — |
3100
+ | `matplotlib` | matplotlib ≥ 2.0 defaults (tab10, viridis, four spines, rounded legend frame) | `matplotlib-classic` (1.x: ticks in on all sides, b g r c m y k, jet) |
3101
+ | `seaborn` | seaborn darkgrid, notebook context, deep, rocket | `seaborn-darkgrid`, `-whitegrid`, `-dark`, `-white`, `-ticks`; `-paper`, `-talk`, `-poster` (scaling 0.8, 1.5, 2) |
3102
+ | `ggplot2` | `theme_grey()`: grey panel, white grid with minor lines, left title, legend outside, `hue` palette | `ggplot2-bw`, `-light`, `-minimal`, `-classic` |
3103
+ | `altair` | Vega-Lite: grey axis lines and grid, view frame, bold titles, hollow points, tableau10, YlGnBu, nice limits | — |
3104
+ | `matlab` | MATLAB R2014b+: ticks in, `lines` colors, parula, hollow circles, nice limits, framed legend | `matlab-box` (box on) |
3105
+ | `chartjs` | Chart.js 4: light grid, grey text, legend boxes on top, translucent points | — |
3106
+ | `plotly` | plotly: blue-grey panel, white grid, no ticks, left title, plasma | `plotly-white` |
3107
+ | `bokeh` | Bokeh 3: light grid and frame, italic axis titles, bold left titles, Category10, framed legend top right | — |
3108
+ | `observable` | Observable Plot: no axis lines or grid, 10 px system font, hollow points, observable10, turbo | — |
3109
+ | `excel` | Excel 2013+: Calibri-like font, grey text, horizontal grid only, Office palette, legend below | — |
3110
+ | `fivethirtyeight` | matplotlib's `fivethirtyeight`: `#f0f0f0` background, large text, thick lines, grid, no ticks | — |
3111
+ | `economist` | ggthemes' `theme_economist`: blue-grey background, white horizontal grid, y labels on the right, red rule above the figure title | — |
3112
+ | `tufte` | ggthemes' `theme_tufte` with a range frame: serif, no grid, axis lines trimmed to the ticks and offset, greys | — |
3113
+
3114
+ Values come from matplotlib's and seaborn's rcParams, ggplot2's `theme-defaults.R`, the
3115
+ Vega and Vega-Lite default configs, Chart.js's defaults, plotly's templates and MATLAB's
3116
+ documented default properties. What cannot be expressed: legend titles naming a variable
3117
+ (series carry no variable names).
3118
+
3119
+ ## 11. Errors
3120
+
3121
+ | Exception | Raised for |
3122
+ |---|---|
3123
+ | `NoFontError` (a `ValueError`, `vec_io.text.NoFontError`) | text with no outline font available at all ([fonts](#1-conventions)) |
3124
+ | `ValueError` | unknown settings or invalid values; mismatched data lengths; grids whose ids are not rectangles; ids outside the grid or taken; a full `rows` × `cols` arrangement; `width` with `plot_width`; a grid `layout` with `rows`/`cols`; ratios of the wrong length; mixed category and numeric series on an axis; limits outside a scale's domain; a colorbar without a mapped source, or of a `ColorMap`; `color_map`, `color_limits` or `color_scale` with a shared `color_axis`; shared color axes with different limits or scales; heatmap value labels on more than 2,500 cells; unknown formats or output options, or options of another format (`dpi` for a PDF, `compress` for an image); unknown bin rules or decreasing bin edges; negative pie values; pies with axis series on one plot; `axline` slopes on non-linear axes; decoration positions that are not categories of a category axis |
3125
+
3126
+ ## 12. Modules
3127
+
3128
+ `pl.__all__` (51 names) is the API. These modules are public too:
3129
+ `plot_io.styles` (`pl.styles`: `names`, `settings`, `register_style`, `set_style`,
3130
+ `use_style`), `plot_io.genome` (`parse_region`, `Region`), `plot_io.markers`
3131
+ (`marker_path`, `marker_area`), `plot_io.color.palettes` (`PALETTE`), and the modules of
3132
+ the types calls return: `plot_io.facets` (`FacetSet`, `LayerSet`), `plot_io.tables`
3133
+ (`SeriesGroup`), `plot_io.colorbar` (`Colorbar`, `FigureColorbar`). The others are internal: their names
3134
+ may change in any release.
3135
+
3136
+ | Module | Role |
3137
+ |---|---|
3138
+ | `settings.py` | `Setting`, `Settings` (validation, the cascade, explain), class rules and `"auto"` rules, keyword routing, validators |
3139
+ | `groups.py` | setting groups (`Font`, `TextStyle`, `Stroke`, `Marker`, `FillStyle`, `NumberFormat`) and their embedding under a prefix |
3140
+ | `defaults.py`, `units.py` | `DEFAULTS`; units, `var()`/`calc()`/`inherit`, `%` referents, `explain` traces |
3141
+ | `spec.py` | a render's specs (the model resolved once, frozen), layout boxes, palette colors and trained color and size axes |
3142
+ | `figure.py`, `plot.py` | `Figure` (arrangement, tracks layout, figure axes, sizes, output), `Plot`, `Title`, `Legend` |
3143
+ | `titles.py`, `markup.py` | the settings plot and figure titles share (`TitleBase`) and a title's text block; markup in strings read into spans |
3144
+ | `rows.py` | row labels in a band left of the plots, groups of rows (`FigureGroup`: letters, labels as figure titles), lines and bands through rows (`FigureVLine`, `FigureVSpan`) |
3145
+ | `axis.py`, `scales.py`, `limits.py`, `ticks.py` | axes, scale functions, limits syntax, tick choice and labels |
3146
+ | `states.py` | the render's state of each plot: calls, palette, axes and their limits, legend, colorbars |
3147
+ | `layout.py`, `geometry.py` | the box model: bands measured around each plot's axes, the grid solved in rounds, the frozen geometry (`layout.layout(fig, fonts)`: text shaped with a font database, no canvas) |
3148
+ | `render.py` | drawing from the geometry; the page of a px document and its outputs (`doc.to_bytes`, `page.render(…).encode`) |
3149
+ | `mapped.py` | color and size axes (`ColorAxis`, `SizeAxis`): own and shared axes of series, their training |
3150
+ | `legend.py`, `colorbar.py` | legend (with size keys) and colorbar: measured, placed, drawn |
3151
+ | `layers/` | plot types as layers: `base.py` (`Series`, the model of a call; `data=`/`group=`), `core.py` (`Layer`, `Call`, `Table`), `stats.py` (columns from data), `positions.py` (stack, dodge, jitter, swarm, packing), `geoms.py` (the eight geoms: extent, drawing, legend symbol, occupancy, hit area), `pipeline.py` (calls per plot, palette training), `paint.py` (colors, mapped values, markers), `context.py` (drawing context, the x↔y swap); `register_layer` |
3152
+ | `presets/` | the plot types (`Scatter`, `Box`, …): settings, and the layers each draws; error bars |
3153
+ | `labels.py`, `shapes.py`, `seams.py` | value labels, bulk rectangles and polygons, seams between touching outlines |
3154
+ | `stats.py` | bins, densities, contours, LOWESS and swarm layout, adapted to plot_io's needs |
3155
+ | `kernels.py`, `_native/` | the numeric kernels (statistics, scaling, gathering) and their C library `plio`: sources, built binaries, bindings generated from `src/plio_api.h` (see `_native/README.md`) |
3156
+ | `decorations.py` | reference lines, spans, text and annotations |
3157
+ | `color/` | colors: `values.py` (the `color` validator, named color scales, palette references, alpha, saturation, luminance), `palettes.py` (palettes: the discrete colors series take in turn; registry, ggplot2's hues), `maps.py` (`ColorMap`: the gradients of color axes and the palette indices or positions of heatmap cells, evaluated in plot_io's C library), `data.py` (bundled map and palette colors) |
3158
+ | `sizemaps.py` | `SizeMap`: the diameters of size axes |
3159
+ | `markers.py`, `lines.py`, `text.py` | marker shapes, line dash styles, one-line text through `vec_io.text`: shaped lines (memoized in the font database, rich content per render), placed runs drawn as shaped, the title's paragraphs |
3160
+ | `styles/` | style registry and expansion; bundled styles (point libraries in `pt`) |
3161
+ | `values.py`, `density.py` | values given to `color`/`size` and their rules; `Density` (point density) |
3162
+ | `tables.py`, `facets.py` | columns of tables, `group=` splitting (`SeriesGroup`); `facet`, `FacetSet`, `LayerSet` |
3163
+ | `sharing.py`, `times.py` | shared axes; dates and times on axes |
3164
+ | `genome/` | genome tracks: `layout.py` (`Tracks`, the `Track` preset), `scale.py` (the genome scale: tick labels, label, origin), `tracks.py` (`BigWig`, `Bed`, `Genes`, `Gtf`, `HiC`: layers over stats `region_signal`, `intervals`, `contact_matrix`; registered layers), `sources.py` (reading readers by their methods), `regions.py`, `pack.py` (rows of intervals) |
3165
+ | `_backend.py` | the vec_io calls plot_io relies on (buffer intake, font databases shared between renders, path areas) |