Skip to main content

Easy publication-ready matplotlib plots for ML papers and posters.

Project description

Agustinus' Very Opiniated Publication-Ready Plotting Library

I love TikZ (btw). I love tikzplotlib. I've been an advocate for the latter (proof). However, tikzplotlib is as good as dead. I need to move on.

[!IMPORTANT] Here's what I use now for all my publication needs. This library is designed to be very opiniated. Beauty is in the eye of the beholder. Also, it is very simple, just a single file and that's it.

[!NOTE] Of course I still use TikZ whenever possible (e.g. Fig. 1 in a paper, diagrams, etc.)

Examples

Left: ICML (letter size), single-column layout. Right: A0 landscape poster, 3-column layout.

       

from pub_ready_plots import get_mpl_rcParams

rc_params, fig_width_in, fig_height_in = get_mpl_rcParams(
    width=1,
    height=0.15,
-   layout="icml",
+   layout="poster-landscape",
)

Installation

Still with me? Still want to use this library? Here's how:

pip install pub-ready-plots

Quick Usage

import pub_ready_plots

with pub_ready_plots.get_context(
    width_frac=1,  # between 0 and 1
    height_frac=0.15,  # between 0 and 1
    nrows=1,  # depending on your subplots
    ncols=2,  # depending on your subplots
    layout="icml",  # or "iclr", "neurips", "poster-portrait", "poster-landscape"
    single_col=False,  # only works for the "icml" layout
    sharey=True,  # Additional keyword args for `plt.subplots`
) as (fig, axs):
    # Do whatever you want with `fig` and `axs`
    ...

    # Once your done, save it, but do NOT set `tight_layout=True`!
    fig.savefig("filename.pdf")

Then in your LaTeX file, include the plot as follows:

\includegraphics[width=\linewidth]{filename.pdf}

[!IMPORTANT] The argument width=\linewidth is crucial!

[!TIP] That's it! But you should use TikZ more. Anyway, see the full, runnable example in examples/simple_plot.py

Using your own styles

Two options:

  1. Use this library and update the resulting rc_params dict with your styles.
  2. Fork this repo and modify things as you wish.

Other libraries

Check out tueplots if you want a more complex library. My library is designed to achieve what I want in my papers and posters, with as little code as possible. Because of this, it is very forkable and hackable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pub_ready_plots-0.2.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

pub_ready_plots-0.2.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pub_ready_plots-0.2.0.tar.gz.

File metadata

  • Download URL: pub_ready_plots-0.2.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.0 CPython/3.9.19 Darwin/23.5.0

File hashes

Hashes for pub_ready_plots-0.2.0.tar.gz
Algorithm Hash digest
SHA256 935565c929d5a8b5e34a9940b468cfcd7bb3389ebc900cab71ac84089ce0dfdd
MD5 fd8cf2f64029558913bb529f39462756
BLAKE2b-256 65b37810b79c3c2d4f9c3212440bd8dc6d91fcd805d1b396875ff26ac782342d

See more details on using hashes here.

File details

Details for the file pub_ready_plots-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pub_ready_plots-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.0 CPython/3.9.19 Darwin/23.5.0

File hashes

Hashes for pub_ready_plots-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b38de55683c4dfe61e7618e800132edb62bebcb94770a42399b7792b7d21cbe
MD5 5a35ca616a6d02e677e3453a2c17df59
BLAKE2b-256 1193011ccb0c0f90f3e14ac7da809a28713d859a5ebb71b9823b6e3aedb0cf75

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page