acadplot 0.1.2__tar.gz → 0.2.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 (29) hide show
  1. acadplot-0.1.2/README.md → acadplot-0.2.0/PKG-INFO +145 -45
  2. acadplot-0.1.2/PKG-INFO → acadplot-0.2.0/README.md +130 -57
  3. acadplot-0.2.0/pyproject.toml +23 -0
  4. acadplot-0.1.2/pyproject.toml → acadplot-0.2.0/pyproject.toml.orig +3 -3
  5. {acadplot-0.1.2 → acadplot-0.2.0}/src/acadplot/__init__.py +1 -1
  6. acadplot-0.2.0/src/acadplot/bar.py +296 -0
  7. {acadplot-0.1.2 → acadplot-0.2.0}/src/acadplot/charts.py +107 -164
  8. acadplot-0.2.0/src/acadplot/draw.py +229 -0
  9. acadplot-0.2.0/src/acadplot/fonts/Arimo-Bold.ttf +0 -0
  10. acadplot-0.2.0/src/acadplot/fonts/Arimo-Italic.ttf +0 -0
  11. acadplot-0.2.0/src/acadplot/fonts/Arimo-Regular.ttf +0 -0
  12. acadplot-0.2.0/src/acadplot/fonts/Inconsolatazi4-Bold.otf +0 -0
  13. acadplot-0.2.0/src/acadplot/fonts/Inconsolatazi4-Regular.otf +0 -0
  14. acadplot-0.2.0/src/acadplot/fonts/LICENSE-Apache-2.0.txt +202 -0
  15. acadplot-0.2.0/src/acadplot/fonts/LICENSE-Inconsolata-OFL.txt +92 -0
  16. acadplot-0.2.0/src/acadplot/fonts/LICENSE-Libertinus-OFL.txt +94 -0
  17. acadplot-0.2.0/src/acadplot/fonts/LibertinusSerif-Bold.otf +0 -0
  18. acadplot-0.2.0/src/acadplot/fonts/LibertinusSerif-Italic.otf +0 -0
  19. acadplot-0.2.0/src/acadplot/fonts/LibertinusSerif-Regular.otf +0 -0
  20. acadplot-0.2.0/src/acadplot/fonts/README.md +17 -0
  21. acadplot-0.2.0/src/acadplot/line.py +85 -0
  22. acadplot-0.2.0/src/acadplot/plot.py +3 -0
  23. {acadplot-0.1.2 → acadplot-0.2.0}/src/acadplot/styles.py +89 -21
  24. {acadplot-0.1.2 → acadplot-0.2.0}/src/acadplot/utils.py +11 -24
  25. acadplot-0.1.2/src/acadplot/bar.py +0 -428
  26. acadplot-0.1.2/src/acadplot/draw.py +0 -126
  27. acadplot-0.1.2/src/acadplot/line.py +0 -184
  28. acadplot-0.1.2/src/acadplot/plot.py +0 -70
  29. {acadplot-0.1.2 → acadplot-0.2.0}/LICENSE +0 -0
@@ -1,8 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: acadplot
3
+ Version: 0.2.0
4
+ Summary: A simple plotting tool using matplotlib for generating plots and subplots for research papers.
5
+ Author: Sudip Bhujel
6
+ Author-email: Sudip Bhujel <code@sudipbhujel.com.np>
7
+ License-Expression: MIT AND OFL-1.1 AND Apache-2.0
8
+ License-File: LICENSE
9
+ License-File: src/acadplot/fonts/LICENSE-Apache-2.0.txt
10
+ License-File: src/acadplot/fonts/LICENSE-Inconsolata-OFL.txt
11
+ License-File: src/acadplot/fonts/LICENSE-Libertinus-OFL.txt
12
+ Requires-Dist: matplotlib>=3.10.8
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+
1
16
  # AcadPlot
2
17
 
3
18
  A simple plotting tool using matplotlib for generating publication-quality plots and subplots for research papers.
4
19
 
5
- AcadPlot defaults to an academic Inconsolata-style setup with LaTeX rendering when available.
20
+ AcadPlot defaults to an academic Inconsolata-style setup. It bundles its fonts and needs no TeX installation; LaTeX rendering is optional.
6
21
 
7
22
  ## Examples
8
23
 
@@ -12,7 +27,7 @@ Regenerate every example from source with:
12
27
  uv run python examples/generate_examples.py
13
28
  ```
14
29
 
15
- The committed examples use LaTeX Inconsolata; regeneration requires a TeX installation with the `zi4` package.
30
+ The examples use the bundled fonts, so regenerating them needs no TeX installation.
16
31
 
17
32
  ### Core Figures
18
33
 
@@ -46,6 +61,17 @@ The committed examples use LaTeX Inconsolata; regeneration requires a TeX instal
46
61
 
47
62
  <img src="https://raw.githubusercontent.com/sudip-bhujel/acadplot/main/examples/utility_panel.png" width="500">
48
63
 
64
+ ### Fonts and Series Styles
65
+
66
+ The four font presets, rendered with the bundled fonts and no TeX:
67
+
68
+ <img src="https://raw.githubusercontent.com/sudip-bhujel/acadplot/main/examples/font_presets.png" width="500">
69
+
70
+ `series_styles` keeps each method's color, marker, and hatch the same across
71
+ plot types:
72
+
73
+ <img src="https://raw.githubusercontent.com/sudip-bhujel/acadplot/main/examples/series_styles.png" width="500">
74
+
49
75
  ### Style Coverage
50
76
 
51
77
  The examples cover all built-in themes and layout profiles:
@@ -71,7 +97,7 @@ The examples cover all built-in themes and layout profiles:
71
97
  - 🎨 Pre-defined color schemes optimized for academic publications
72
98
  - 🖋️ Theme-controlled axis, tick, and legend colors for consistent figures
73
99
  - 🔷 Multiple marker styles for distinguishing data series
74
- - 📐 LaTeX support for mathematical notation
100
+ - 📐 Math notation without TeX, with optional LaTeX rendering
75
101
  - 🔧 Customizable plot elements (ticks, grids, legends)
76
102
  - 📈 Line, bar, scatter, error-bar, box, and heatmap chart helpers
77
103
  - 💾 Publication-safe `save()` utility for PNG, PDF, and SVG output
@@ -105,6 +131,7 @@ pip install -e .
105
131
 
106
132
  - Python >= 3.12
107
133
  - matplotlib >= 3.10.8
134
+ - No TeX installation needed (optional, for `latex=True`)
108
135
 
109
136
  ## Usage
110
137
 
@@ -220,16 +247,31 @@ Layout defaults:
220
247
  | `presentation` | `7.2 x 4.2 in` | large labels and heavier marks | slides and talks |
221
248
 
222
249
  `paper-2col-subplot` intentionally uses smaller tick labels than axis labels:
223
- `tick_size=4.8`, `legend_size=5.0`, `label_size=5.8`, and `title_size=5.8`.
250
+ `tick_size=5.5`, `legend_size=5.5`, `label_size=5.8`, and `title_size=5.8`.
224
251
  This keeps dense two-panel figures legible without letting x/y tick labels
225
252
  dominate the plot area.
226
253
 
227
- Use `font="libertine"` when a serif academic style is preferred:
254
+ Pick the font preset that matches the paper's body text. Every preset works
255
+ without TeX or system fonts: AcadPlot bundles the font files (licenses in
256
+ [`src/acadplot/fonts`](src/acadplot/fonts/README.md)) and uses Matplotlib's
257
+ built-in math rendering.
258
+
259
+ | Preset | Matches | Font used | LaTeX packages (`latex=True`) |
260
+ |---|---|---|---|
261
+ | `inconsolata` (default) | ACM's code font; a monospace look | Inconsolatazi4 (bundled) | `zi4`, `mathastext` |
262
+ | `libertine` | ACM (`acmart`) body text | Libertinus Serif (bundled) | `libertine`, `newtxmath` |
263
+ | `times` | IEEE and most ML conference templates | STIXGeneral (ships with Matplotlib) | `newtxtext`, `newtxmath` |
264
+ | `helvetica` | journals that ask for sans-serif, such as Nature and Science | Arimo (bundled, Arial-compatible) | `helvet`, `mathastext` |
228
265
 
229
266
  ```python
230
- configure_plot_style(layout="paper-2col", theme="classic", font="libertine")
267
+ configure_plot_style(layout="paper-2col", theme="classic", font="times")
231
268
  ```
232
269
 
270
+ Each preset sets tick numbers in its own text font. Inconsolata has no matching
271
+ 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`.
274
+
233
275
  For two subplots inside one column of a two-column paper, let the layout drive
234
276
  the figure size:
235
277
 
@@ -254,6 +296,28 @@ fig.subplots_adjust(left=0.14, right=0.99, bottom=0.24, top=0.86, wspace=0.18)
254
296
  save(fig, "one_column_two_panel.pdf", tight_layout=False)
255
297
  ```
256
298
 
299
+ ### Consistent Series Styles
300
+
301
+ Give each method one color, marker, and bar pattern for the whole paper:
302
+
303
+ ```python
304
+ configure_plot_style(
305
+ layout="paper-2col",
306
+ series_styles={
307
+ "Ours": {"color": "red", "marker": "circle"},
308
+ "Baseline": {"color": "gray", "marker": "square", "pattern": "diagonal"},
309
+ },
310
+ )
311
+
312
+ plot_line([(x, y_ours, "Ours"), (x, y_base, "Baseline")])
313
+ plot_grouped_bar(datasets, [(acc_ours, "Ours"), (acc_base, "Baseline")])
314
+ ```
315
+
316
+ A color, marker, or pattern written in the data tuple still wins, and a
317
+ per-call `patterns=` argument beats a mapped pattern. Series without an entry
318
+ use the theme palette and marker cycle as before. Theme color names such as
319
+ `"red"` follow the active theme.
320
+
257
321
  ### Saving Figures
258
322
 
259
323
  Plot functions save directly when `fname` is provided. For manual figures,
@@ -363,7 +427,7 @@ Available fonts:
363
427
  from acadplot import available_fonts
364
428
 
365
429
  print(available_fonts())
366
- # ("libertine", "inconsolata", "serif", "sans")
430
+ # ("libertine", "inconsolata", "times", "helvetica", "serif", "sans")
367
431
  ```
368
432
 
369
433
  The default `classic` cycle uses a muted publication palette inspired by Paul
@@ -386,10 +450,13 @@ You can also override font size for one plot call:
386
450
  plot_line(data, location="upper left", font_size=10.5, fname="column_plot.pdf")
387
451
  ```
388
452
 
389
- Use `latex="auto"` to use LaTeX only when the local TeX installation and required font package are available:
453
+ LaTeX rendering is off by default, so figures look the same on every machine.
454
+ Pass `latex=True` to render text with a local TeX installation and the packages
455
+ listed in the font table, or `latex="auto"` to use LaTeX only when those are
456
+ available. With LaTeX on, escape `%` in labels as `\%`:
390
457
 
391
458
  ```python
392
- configure_plot_style(layout="paper-2col", latex="auto")
459
+ configure_plot_style(layout="paper-2col", latex=True)
393
460
  ```
394
461
 
395
462
  ### Basic Plot
@@ -401,6 +468,7 @@ configure_plot_style(layout="paper-1col", theme="classic")
401
468
 
402
469
  # Define your data: (x_values, y_values, marker, label)
403
470
  # Colors are optional; omitted colors use the active professional theme palette.
471
+ # Markers are optional too: (x_values, y_values, label) cycles distinct filled markers.
404
472
  data = [
405
473
  ([10, 20, 30, 40, 50], [5, 10, 15, 20, 25], "x_filled", "Method A"),
406
474
  ([10, 20, 30, 40, 50], [6, 11, 14, 18, 22], "square", "Method B"),
@@ -415,7 +483,7 @@ plot_line(
415
483
  grid="major",
416
484
  ystart=0,
417
485
  yticks=range(0, 30, 5),
418
- fname="output.pdf"
486
+ fname="output.pdf",
419
487
  )
420
488
  ```
421
489
 
@@ -437,7 +505,7 @@ plot_line(
437
505
  location="upper left",
438
506
  fig_size=(5, 3), # Custom figure size (width, height)
439
507
  label=("X-axis Label", "Y-axis Label"),
440
- fname="large_plot.pdf"
508
+ fname="large_plot.pdf",
441
509
  )
442
510
  ```
443
511
 
@@ -484,13 +552,9 @@ data = [
484
552
 
485
553
  fig, axes = plt.subplots(1, 2, figsize=(6, 2))
486
554
 
487
- # Plot on each subplot
488
- plot_line(data, "upper left", ax=axes[0], fname=None)
489
- plot_line(data, "upper right", ax=axes[1], fname=None)
490
-
491
- # Remove individual legends
492
- axes[0].get_legend().remove()
493
- axes[1].get_legend().remove()
555
+ # Plot on each subplot without per-panel legends
556
+ plot_line(data, location=None, ax=axes[0])
557
+ plot_line(data, location=None, ax=axes[1])
494
558
 
495
559
  # Get handles and labels from one subplot
496
560
  handles, labels = axes[0].get_legend_handles_labels()
@@ -533,7 +597,7 @@ plot_bar(
533
597
  location="upper left",
534
598
  label=("X-axis Label", "Y-axis Label"),
535
599
  xticklabels=["Group A", "Group B", "Group C"],
536
- fname="single_bar.pdf"
600
+ fname="single_bar.pdf",
537
601
  )
538
602
  ```
539
603
 
@@ -544,17 +608,18 @@ from acadplot import plot_grouped_bar, configure_plot_style
544
608
 
545
609
  configure_plot_style()
546
610
 
547
- grouped_data = [
548
- ("Dataset A", [(10, "Train"), (8, "Val")]),
549
- ("Dataset B", [(15, "Train"), (12, "Val")]),
550
- ("Dataset C", [(12, "Train"), (14, "Val")]),
611
+ categories = ["Dataset A", "Dataset B", "Dataset C"]
612
+ series = [
613
+ ([10, 15, 12], "Train"),
614
+ ([8, 12, 14], "Val"),
551
615
  ]
552
616
 
553
617
  plot_grouped_bar(
554
- grouped_data,
618
+ categories,
619
+ series,
555
620
  location="upper left",
556
621
  label=("X-axis Label", "Y-axis Label"),
557
- fname="grouped_bar.pdf"
622
+ fname="grouped_bar.pdf",
558
623
  )
559
624
  ```
560
625
 
@@ -574,10 +639,10 @@ print(available_patterns())
574
639
  configure_plot_style(layout="paper-1col", theme="colorblind", text_color="dark")
575
640
 
576
641
  plot_grouped_bar(
642
+ ["Dataset A", "Dataset B", "Dataset C"],
577
643
  [
578
- ("Dataset A", [(81.2, "Baseline"), (83.5, "AcadPlot")]),
579
- ("Dataset B", [(84.4, "Baseline"), (86.2, "AcadPlot")]),
580
- ("Dataset C", [(86.1, "Baseline"), (88.0, "AcadPlot")]),
644
+ ([81.2, 84.4, 86.1], "Baseline"),
645
+ ([83.5, 86.2, 88.0], "AcadPlot"),
581
646
  ],
582
647
  location="upper left",
583
648
  label=("Dataset", "Score"),
@@ -619,7 +684,7 @@ plot_stacked_bar(
619
684
  stacks,
620
685
  location="upper left",
621
686
  label=("X-axis Label", "Y-axis Label"),
622
- fname="stacked_bar.pdf"
687
+ fname="stacked_bar.pdf",
623
688
  )
624
689
  ```
625
690
 
@@ -715,10 +780,25 @@ Available color names or indices (0-19):
715
780
 
716
781
  ```python
717
782
  colors = {
718
- "blue", "orange", "green", "purple", "brown", "yellow",
719
- "sky_blue", "gray", "red", "pink", "teal", "olive",
720
- "navy", "maroon", "lime", "cyan", "magenta",
721
- "dark_gray", "light_gray"
783
+ "blue",
784
+ "orange",
785
+ "green",
786
+ "purple",
787
+ "brown",
788
+ "yellow",
789
+ "sky_blue",
790
+ "gray",
791
+ "red",
792
+ "pink",
793
+ "teal",
794
+ "olive",
795
+ "navy",
796
+ "maroon",
797
+ "lime",
798
+ "cyan",
799
+ "magenta",
800
+ "dark_gray",
801
+ "light_gray",
722
802
  }
723
803
  ```
724
804
 
@@ -728,12 +808,32 @@ Use marker names or indices (0-26):
728
808
 
729
809
  ```python
730
810
  markers = {
731
- "square", "triangle_up", "pentagon", "circle", "star",
732
- "plus_filled", "triangle_down", "diamond", "x_filled",
733
- "triangle_left", "triangle_right", "thin_diamond",
734
- "hexagon1", "hexagon2", "plus", "x", "vline", "hline",
735
- "point", "pixel", "tri_down", "tri_up", "tri_left",
736
- "tri_right", "octagon", "none"
811
+ "square",
812
+ "triangle_up",
813
+ "pentagon",
814
+ "circle",
815
+ "star",
816
+ "plus_filled",
817
+ "triangle_down",
818
+ "diamond",
819
+ "x_filled",
820
+ "triangle_left",
821
+ "triangle_right",
822
+ "thin_diamond",
823
+ "hexagon1",
824
+ "hexagon2",
825
+ "plus",
826
+ "x",
827
+ "vline",
828
+ "hline",
829
+ "point",
830
+ "pixel",
831
+ "tri_down",
832
+ "tri_up",
833
+ "tri_left",
834
+ "tri_right",
835
+ "octagon",
836
+ "none",
737
837
  }
738
838
  ```
739
839
 
@@ -743,10 +843,10 @@ markers = {
743
843
 
744
844
  **Parameters:**
745
845
 
746
- - `lines` (List[Tuple]): List of lines to plot, each defined by `(x_values, y_values, marker, label)` or `(x_values, y_values, color, marker, label)`
747
- - `location` (str): Location of the legend (e.g., "upper left", "lower right")
846
+ - `lines` (List[Tuple]): List of lines to plot, each defined by `(x_values, y_values, label)`, `(x_values, y_values, marker, label)`, or `(x_values, y_values, color, marker, label)`
847
+ - `location` (str | None): Location of the legend (e.g., "upper left", "lower right"). Default: `"best"`. Pass `None` for no legend; this works the same in every plot function
748
848
  - `fig_size` (Tuple[float, float]): Figure size (width, height) in inches. Defaults to the active layout profile
749
- - `label` (Tuple[str, str]): Labels for x and y axes. Default: `("x-label", "y-label")`
849
+ - `label` (Tuple[str, str]): Labels for x and y axes. Default: `None` (no labels)
750
850
  - `ax` (Optional[plt.Axes]): Axes to plot on. Creates new if None
751
851
  - `xticks` (Optional[List[float] | range]): Custom x-axis ticks
752
852
  - `yticks` (Optional[List[float] | range]): Custom y-axis ticks
@@ -754,15 +854,15 @@ markers = {
754
854
  - `ystart` (Optional[float]): Minimum y-axis value
755
855
  - `font_size` (int): Font size for the plot. Defaults to the active layout profile
756
856
  - `grid` (str): Grid preset: `"major-y"`, `"major"`, `"major-minor"`, or `"none"`
757
- - `fname` (Optional[str]): Filename to save the plot. Default: `"plot.pdf"`
857
+ - `fname` (Optional[str]): Filename to save the plot. Default: `None` (not saved)
758
858
 
759
859
  ### `draw(ax, x, y, color_key, marker_key, label)`
760
860
 
761
861
  Draw a single line with markers on the given axes.
762
862
 
763
- ### `configure_plot_style(layout, theme, font, latex, font_size, label_size, tick_size, legend_size, title_size, scale, text_color)`
863
+ ### `configure_plot_style(layout, theme, font, latex, font_size, label_size, tick_size, legend_size, title_size, scale, text_color, series_styles)`
764
864
 
765
- Configure global plot style settings with LaTeX rendering. Layouts and themes
865
+ Configure global plot style settings. Layouts and themes
766
866
  are composable. Each layout has its own default figure size and typography, but
767
867
  explicit `font_size`, `label_size`, `tick_size`, `legend_size`, and `title_size`
768
868
  arguments always override those defaults. Use `text_color` as a universal text