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.)
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",
)
Still with me? Still want to use this library? Here's how:
pip install pub-ready-plots
rc_params, fig_width_in, fig_height_in = pub_ready_plots.get_mpl_rcParams(
width=1, # between 0 and 1
height=0.1, # between 0 and 1
layout="icml" # or "iclr", "neurips", "poster-portrait", "poster-landscape"
)
plt.rcParams.update(rc_params)
fig, axs = plt.subplots(
nrows,
ncols,
constrained_layout=True, # Important!
)
fig.set_size_inches(fig_width_in, fig_height_in)
# Your plot here!
plt.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.
Two options:
- Fork this repo and modify things as you wish.
- Use this library and update the resulting
rc_params
dict with your styles.
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.