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.
import pub_ready_plots
...
pub_ready_plots.get_context(
...
- 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, # Multiplier for `\linewidth`
height_frac=0.15, # Multiplier for `\textheight`
layout="icml", # or "iclr", "neurips", "aistats", "uai", "tmlr", "poster-portrait", "poster-landscape"
single_col=False, # only works for the "icml", "aistats", "uai" layouts
nrows=1, # depending on your subplots, default = 1
ncols=2, # depending on your subplots, default = 1
override_rc_params={"lines.linewidth": 4.123}, # Overriding rcParams
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! Also, do not specify theheight
option! Otherwise, your plot is distorted. (All measurements have been done inpub-ready-plots
.)
That's it! But you should use TikZ more.
Anyway, see the full, runnable example in examples/simple_plot.py
[!TIP] I recommend using this library in conjunction with pypalettes to avoid the generic blue-orange Matplotlib colors. Distinguish your plots from others!
Advanced usages
Creating plots for \wrapfigure
Say we want to have an inline figure of size 0.4\textwidth
and
height 0.15\textheight
in our NeurIPS paper.
Then all we have to do is the following:
import pub_ready_plots
with pub_ready_plots.get_context(
width_frac=0.4, height_frac=0.15, layout="neurips",
) as (fig, axs):
# Your plot here!
...
fig.savefig("mywrapfigure.pdf")
In our LaTeX doc, we can then use the wrapfig
package and do the following:
Some paragraph.
\begin{wrapfigure}[11]{r}{0.4\textwidth}
\centering
\includegraphics[width=\linewidth]{mywrapfigure.pdf}
...
\end{wrapfigure}
Some other paragraph.
[!IMPORTANT] In the
\begin{wrapfigure}
statement, specify the correct figure size (in our case,0.4\textwidth
). Then, in the\includegraphics
statement, always specifywidth=\linewidth
without specifying the height.
Using your own styles
Two options:
- Use this library and update the resulting
rc_params
dict with your styles. - 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
Built Distribution
File details
Details for the file pub_ready_plots-1.0.tar.gz
.
File metadata
- Download URL: pub_ready_plots-1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.18.1 CPython/3.9.19 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf602659a39733be34cd03e60fae036b649fe7471bf5fd148c8da1cd16ed1c9c |
|
MD5 | a3d10c0acbf9682a730c27a1853f123b |
|
BLAKE2b-256 | 51d17acb2be435635b1ceab9805cd8819b70076e5b803ba9fc9cb4274661171d |
File details
Details for the file pub_ready_plots-1.0-py3-none-any.whl
.
File metadata
- Download URL: pub_ready_plots-1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.18.1 CPython/3.9.19 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba97aa2e7aef88d47c79953e8648fe6cc70ee4a886dd720e21fb39d7c9551d58 |
|
MD5 | f98100f9f3c72141d0aea851867701ae |
|
BLAKE2b-256 | 3f9cfd256f00834243fe2f677efe08da78020b82abc59532ca86401165d4e2b5 |