acadplot 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.
acadplot/__init__.py CHANGED
@@ -31,7 +31,7 @@ from .utils import (
31
31
  theme_preview,
32
32
  )
33
33
 
34
- __version__ = "0.2.0"
34
+ __version__ = "0.3.0"
35
35
  __all__ = [
36
36
  "plot_line",
37
37
  "plot_bar",
acadplot/styles.py CHANGED
@@ -74,6 +74,8 @@ class FontPreset:
74
74
  latex_packages: tuple[str, ...]
75
75
  # Matplotlib mathtext set for $...$ without TeX; "custom" uses the preset font.
76
76
  mathtext_fontset: str = "custom"
77
+ # Format tick labels as math, for fonts without a Unicode minus sign.
78
+ mathtext_ticks: bool = False
77
79
 
78
80
 
79
81
  BASE_COLORS = {
@@ -422,6 +424,18 @@ FONTS = {
422
424
  ),
423
425
  latex_packages=("helvet.sty", "mathastext.sty"),
424
426
  ),
427
+ # Computer Modern ships with Matplotlib. cmr10 has no Unicode minus sign, so
428
+ # tick labels go through mathtext to get one.
429
+ "computer-modern": FontPreset(
430
+ family="serif",
431
+ serif=("cmr10", "DejaVu Serif"),
432
+ sans_serif=("cmss10", "DejaVu Sans"),
433
+ monospace=("cmtt10", "DejaVu Sans Mono"),
434
+ latex_preamble="",
435
+ latex_packages=(),
436
+ mathtext_fontset="cm",
437
+ mathtext_ticks=True,
438
+ ),
425
439
  }
426
440
  # Older preset names, kept so existing calls keep working.
427
441
  FONTS["serif"] = FONTS["times"]
@@ -638,7 +652,7 @@ def _latex_available(font: str) -> bool:
638
652
  return True
639
653
 
640
654
 
641
- _CURRENT_STYLE = _build_style("paper-1col", "classic", "inconsolata", False)
655
+ _CURRENT_STYLE = _build_style("paper-1col", "colorblind", "inconsolata", False)
642
656
 
643
657
 
644
658
  def available_layouts() -> tuple[str, ...]:
@@ -707,6 +721,7 @@ def _apply_rcparams(style: dict[str, object]) -> None:
707
721
  "mathtext.rm": primary_font,
708
722
  "mathtext.it": f"{primary_font}:italic",
709
723
  "mathtext.bf": f"{primary_font}:bold",
724
+ "axes.formatter.use_mathtext": font.mathtext_ticks,
710
725
  "font.family": font.family,
711
726
  "font.serif": list(font.serif),
712
727
  "font.sans-serif": list(font.sans_serif),
@@ -755,7 +770,7 @@ def _apply_rcparams(style: dict[str, object]) -> None:
755
770
 
756
771
  def configure_plot_style(
757
772
  layout: str = "paper-1col",
758
- theme: str = "classic",
773
+ theme: str = "colorblind",
759
774
  font: str = "inconsolata",
760
775
  latex: LatexMode = False,
761
776
  font_size: float | None = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acadplot
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A simple plotting tool using matplotlib for generating plots and subplots for research papers.
5
5
  Author: Sudip Bhujel
6
6
  Author-email: Sudip Bhujel <code@sudipbhujel.com.np>
@@ -63,9 +63,11 @@ The examples use the bundled fonts, so regenerating them needs no TeX installati
63
63
 
64
64
  ### Fonts and Series Styles
65
65
 
66
- The four font presets, rendered with the bundled fonts and no TeX:
66
+ Each font preset with the venues it suits (see
67
+ [Choosing a Style for Your Venue](#choosing-a-style-for-your-venue)),
68
+ rendered with no TeX:
67
69
 
68
- <img src="https://raw.githubusercontent.com/sudip-bhujel/acadplot/main/examples/font_presets.png" width="500">
70
+ <img src="https://raw.githubusercontent.com/sudip-bhujel/acadplot/main/examples/venue_gallery.png" width="600">
69
71
 
70
72
  `series_styles` keeps each method's color, marker, and hatch the same across
71
73
  plot types:
@@ -76,13 +78,13 @@ plot types:
76
78
 
77
79
  The examples cover all built-in themes and layout profiles:
78
80
 
79
- - `classic` with `paper-1col`: line plot
80
- - `classic` with `paper-2col`: compact monospace line plot
81
- - `nature` with `paper-1col`: bar plot
82
- - `colorblind` with `paper-2col`: grouped bar plot for one column in a two-column paper
81
+ - `colorblind` (default) with `paper-1col`: line plot
82
+ - `colorblind` with `paper-2col`: compact monospace line plot and grouped bar plot for one column in a two-column paper
83
83
  - `colorblind` with `paper-2col-subplot`: two small subplots inside one column of a two-column paper
84
+ - `nature` with `paper-1col`: bar plot
84
85
  - `mono` with `paper-1col`: stacked bar plot
85
86
  - `warm` with `presentation`: presentation-scale line plot
87
+ - all five themes, including `classic`: style gallery
86
88
 
87
89
  <img src="https://raw.githubusercontent.com/sudip-bhujel/acadplot/main/examples/presentation_style.png" width="500">
88
90
 
@@ -262,6 +264,7 @@ built-in math rendering.
262
264
  | `libertine` | ACM (`acmart`) body text | Libertinus Serif (bundled) | `libertine`, `newtxmath` |
263
265
  | `times` | IEEE and most ML conference templates | STIXGeneral (ships with Matplotlib) | `newtxtext`, `newtxmath` |
264
266
  | `helvetica` | journals that ask for sans-serif, such as Nature and Science | Arimo (bundled, Arial-compatible) | `helvet`, `mathastext` |
267
+ | `computer-modern` | Springer LNCS, Elsevier, plain LaTeX | Computer Modern (ships with Matplotlib) | none (the LaTeX default) |
265
268
 
266
269
  ```python
267
270
  configure_plot_style(layout="paper-2col", theme="classic", font="times")
@@ -269,8 +272,9 @@ configure_plot_style(layout="paper-2col", theme="classic", font="times")
269
272
 
270
273
  Each preset sets tick numbers in its own text font. Inconsolata has no matching
271
274
  math font, so Greek letters and math symbols in labels (such as `$\alpha$`)
272
- still render in a serif math font. `serif` and `sans` remain as aliases of
273
- `times` and `helvetica`.
275
+ still render in a serif math font. Matplotlib's Computer Modern has no bold
276
+ face in the same family, so bold text such as panel labels renders in regular
277
+ weight. `serif` and `sans` remain as aliases of `times` and `helvetica`.
274
278
 
275
279
  For two subplots inside one column of a two-column paper, let the layout drive
276
280
  the figure size:
@@ -296,6 +300,96 @@ fig.subplots_adjust(left=0.14, right=0.99, bottom=0.24, top=0.86, wspace=0.18)
296
300
  save(fig, "one_column_two_panel.pdf", tight_layout=False)
297
301
  ```
298
302
 
303
+ ### Choosing a Style for Your Venue
304
+
305
+ Match the figure font to the paper's body text and draw the figure at the width
306
+ it will be printed, so point sizes in the PDF are the sizes readers see. Where a
307
+ column is narrower than `paper-2col` (3.35 in), the table gives a `fig_size` to
308
+ pass to each plot call.
309
+
310
+ **Security conferences**
311
+
312
+ | Venue | Template and body font | `font=` | One-column figure | Full-width figure |
313
+ |---|---|---|---|---|
314
+ | IEEE S&P | `IEEEtran`, Times | `"times"` | `paper-2col` (column 3.49 in) | `paper-2col-span` (7.14 in) |
315
+ | USENIX Security | `usenix-2020-09`, Times | `"times"` | `paper-2col` (column 3.33 in) | `paper-2col-span` (7.0 in) |
316
+ | ACM CCS | `acmart` `sigconf`, Libertine | `"libertine"` | `paper-2col` (column 3.33 in) | `paper-2col-span` (7.01 in) |
317
+ | NDSS | IEEE conference template, Times | `"times"` | `paper-2col` (column 3.49 in) | `paper-2col-span` (7.14 in) |
318
+
319
+ **Machine learning conferences**
320
+
321
+ | Venue | Template and body font | `font=` | One-column figure | Full-width figure |
322
+ |---|---|---|---|---|
323
+ | NeurIPS | NeurIPS style, Times | `"times"` | single column | `paper-1col` (5.5 in) |
324
+ | ICLR | ICLR style, Times | `"times"` | single column | `paper-1col` (5.5 in) |
325
+ | ICML | ICML style, Times | `"times"` | `fig_size=(3.25, 2.1)` (column 3.25 in) | `fig_size=(6.7, 2.8)` (6.75 in) |
326
+ | CVPR, ICCV | CVPR author kit, Times | `"times"` | `fig_size=(3.25, 2.1)` (column 3.28 in) | `paper-2col-span` (6.875 in) |
327
+ | ECCV | Springer LNCS, Computer Modern | `"computer-modern"` | single column | `fig_size=(4.8, 2.8)` (4.8 in) |
328
+ | ACL, EMNLP, NAACL | ACL style, Times | `"times"` | `fig_size=(3.0, 1.95)` (column 3.03 in) | `fig_size=(6.3, 2.6)` (6.3 in) |
329
+ | AAAI | AAAI style, Times | `"times"` | `paper-2col` | `paper-2col-span` |
330
+ | KDD | `acmart` `sigconf`, Libertine | `"libertine"` | `paper-2col` (column 3.33 in) | `paper-2col-span` (7.01 in) |
331
+
332
+ **Journals and other venues**
333
+
334
+ | Venue | Body font | `font=` | One-column figure | Full-width figure |
335
+ |---|---|---|---|---|
336
+ | IEEE Transactions | Times | `"times"` | `paper-2col` (column 3.49 in) | `paper-2col-span` (7.14 in) |
337
+ | Nature, Science, Cell | journals ask for sans-serif figure text | `"helvetica"`; for Nature add `font_size=7` (5–7 pt) | `paper-2col` (Nature: 89 mm) | `paper-2col-span` (Nature: 183 mm) |
338
+ | Springer LNCS, Elsevier `elsarticle`, plain LaTeX, theses | Computer Modern | `"computer-modern"` | single column | `fig_size=(4.8, 2.8)` (LNCS: 4.8 in) |
339
+ | Slides | — | `"helvetica"` | — | `presentation` |
340
+
341
+ On ACM venues, `font="inconsolata"` (the default) matches `acmart`'s code font
342
+ if you prefer a code-style look. Templates and journal rules change, so check
343
+ the current author guide. A few rules hold everywhere:
344
+
345
+ - Include the PDF at its natural size, `\includegraphics{figure.pdf}` without a
346
+ `width=`, so text keeps the size AcadPlot set. Scaling a figure to fit also
347
+ scales its text.
348
+ - Pass the same `fig_size=` to every plot call in a paper, or to
349
+ `plt.subplots(figsize=...)` for figures you build yourself.
350
+ - `fig_size` changes only the canvas; text keeps the layout's font sizes.
351
+
352
+ Example: a one-column figure for an IEEE S&P paper.
353
+
354
+ ```python
355
+ from acadplot import configure_plot_style, plot_line, save
356
+
357
+ configure_plot_style(layout="paper-2col", font="times")
358
+
359
+ fig, _ = plot_line(
360
+ [
361
+ ([1, 2, 3, 4, 5], [76.0, 79.5, 82.0, 83.0, 84.0], "Ours"),
362
+ ([1, 2, 3, 4, 5], [74.0, 77.0, 79.0, 80.5, 81.5], "Baseline"),
363
+ ],
364
+ location="lower right",
365
+ label=("Training budget", "Accuracy (%)"),
366
+ )
367
+ save(fig, "accuracy.pdf")
368
+ ```
369
+
370
+ ```latex
371
+ \begin{figure}
372
+ \centering
373
+ \includegraphics{accuracy.pdf}
374
+ \caption{Accuracy versus training budget.}
375
+ \end{figure}
376
+ ```
377
+
378
+ <img src="https://raw.githubusercontent.com/sudip-bhujel/acadplot/main/examples/venue_ieee.png" width="335">
379
+
380
+ For other venues, change the style line and add `fig_size=` where the table
381
+ lists one:
382
+
383
+ ```python
384
+ configure_plot_style(layout="paper-2col", font="times") # IEEE S&P, USENIX, NDSS, AAAI
385
+ configure_plot_style(layout="paper-2col", font="libertine") # ACM CCS, KDD
386
+ configure_plot_style(layout="paper-1col", font="times") # NeurIPS, ICLR
387
+ configure_plot_style(layout="paper-2col", font="times") # ICML, CVPR: plot_line(..., fig_size=(3.25, 2.1))
388
+ configure_plot_style(layout="paper-2col", font="times") # ACL, EMNLP: plot_line(..., fig_size=(3.0, 1.95))
389
+ configure_plot_style(layout="paper-1col", font="computer-modern") # ECCV, LNCS: plot_line(..., fig_size=(4.8, 2.8))
390
+ configure_plot_style(layout="paper-2col", font="helvetica", font_size=7) # Nature
391
+ ```
392
+
299
393
  ### Consistent Series Styles
300
394
 
301
395
  Give each method one color, marker, and bar pattern for the whole paper:
@@ -427,13 +521,14 @@ Available fonts:
427
521
  from acadplot import available_fonts
428
522
 
429
523
  print(available_fonts())
430
- # ("libertine", "inconsolata", "times", "helvetica", "serif", "sans")
524
+ # ("libertine", "inconsolata", "times", "helvetica", "computer-modern", "serif", "sans")
431
525
  ```
432
526
 
433
- The default `classic` cycle uses a muted publication palette inspired by Paul
434
- Tol's qualitative color schemes, so omitted colors are less saturated than
435
- Matplotlib defaults while remaining distinct on screen and paper. Use
436
- `theme="colorblind"` for an Okabe-Ito style accessible palette.
527
+ The default `colorblind` theme uses the Okabe-Ito palette, which stays
528
+ distinguishable for the most common forms of color blindness, in print, and on
529
+ projectors. Use `theme="classic"` for a quieter, muted palette inspired by Paul
530
+ Tol's qualitative schemes, `mono` for grayscale-only venues, and `warm` for
531
+ slides.
437
532
 
438
533
  Use a temporary style override when needed:
439
534
 
@@ -1,4 +1,4 @@
1
- acadplot/__init__.py,sha256=fpwdM-CuxUvPugyi51_XghXgDHbhlA5QfQSnjOZN5Ds,1393
1
+ acadplot/__init__.py,sha256=8Uuw0Fl3HJz629wQswxuHUFSHpDTcggzBG_d-eMcFuU,1393
2
2
  acadplot/bar.py,sha256=RMLWBZji4xxwouzU12PnNYvaN5Zbqqysw5ihoOJ18mw,12609
3
3
  acadplot/charts.py,sha256=ONV8BJr_Fq1j5BdSpGt7UKnWwyk-XmhBrTqOJs9S0Qs,10365
4
4
  acadplot/draw.py,sha256=sVc5N2FcJxEMKBMitWwGk_oeCv3hdh6EGGxmIDUGiZc,7670
@@ -16,12 +16,12 @@ acadplot/fonts/LibertinusSerif-Regular.otf,sha256=6soCE6uQfjZSSqYRMO1bj6qMCw9U50
16
16
  acadplot/fonts/README.md,sha256=TUv2mjUaRIIsAe-z2dCui5lNN9vXYz1CmmDM7SIUlMc,1065
17
17
  acadplot/line.py,sha256=n6OHvVEn1SwvyJEOZE878pOoS2BTukBBaDJcobG2WrI,3560
18
18
  acadplot/plot.py,sha256=8Vixqr0zfG6Q58fS8XERWM-DSI02ttjwGVQBbjUzXec,149
19
- acadplot/styles.py,sha256=1eSziAE0oz1KOPcQxhF5vbpsneNtkU1Hp4x4Chft-8k,31664
19
+ acadplot/styles.py,sha256=8tgaEAaqdNdvRvkoyY6mvlurjwH3WqZ6w10ZIU9o7ts,32289
20
20
  acadplot/utils.py,sha256=rtPpm9gYE9eIOMCQFrEj-z0q2d022f-lTEA2HNgz4JY,12316
21
- acadplot-0.2.0.dist-info/licenses/LICENSE,sha256=JmrbnmdwxT_DLcz_9e6_P1HmWKB4rZGF_xpfiWzQxgk,1069
22
- acadplot-0.2.0.dist-info/licenses/src/acadplot/fonts/LICENSE-Apache-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
23
- acadplot-0.2.0.dist-info/licenses/src/acadplot/fonts/LICENSE-Inconsolata-OFL.txt,sha256=J4XDM81zMWIi1ZbKU16NLMLWp4gzMBxFubYK798o0hM,4406
24
- acadplot-0.2.0.dist-info/licenses/src/acadplot/fonts/LICENSE-Libertinus-OFL.txt,sha256=mu7MgQfEiewewAaLAxPlMadg7fNJNwWzKrirghWoeU4,4426
25
- acadplot-0.2.0.dist-info/WHEEL,sha256=R1d3uUTbmXM1FHXH_itQashbrqrOSVj-hvBCpmkIIGE,81
26
- acadplot-0.2.0.dist-info/METADATA,sha256=F7Gj221gNU5ctaCpQ9gas5WWTcICNjV_GlfcfmoZAps,26870
27
- acadplot-0.2.0.dist-info/RECORD,,
21
+ acadplot-0.3.0.dist-info/licenses/LICENSE,sha256=JmrbnmdwxT_DLcz_9e6_P1HmWKB4rZGF_xpfiWzQxgk,1069
22
+ acadplot-0.3.0.dist-info/licenses/src/acadplot/fonts/LICENSE-Apache-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
23
+ acadplot-0.3.0.dist-info/licenses/src/acadplot/fonts/LICENSE-Inconsolata-OFL.txt,sha256=J4XDM81zMWIi1ZbKU16NLMLWp4gzMBxFubYK798o0hM,4406
24
+ acadplot-0.3.0.dist-info/licenses/src/acadplot/fonts/LICENSE-Libertinus-OFL.txt,sha256=mu7MgQfEiewewAaLAxPlMadg7fNJNwWzKrirghWoeU4,4426
25
+ acadplot-0.3.0.dist-info/WHEEL,sha256=R1d3uUTbmXM1FHXH_itQashbrqrOSVj-hvBCpmkIIGE,81
26
+ acadplot-0.3.0.dist-info/METADATA,sha256=5z17sKVToBVSW8E3-FusUk8sB04jyarORFPgTlt_qsg,31949
27
+ acadplot-0.3.0.dist-info/RECORD,,