TuePlots.jl

A light-weight library to help you create better plots for scientific publications, by taking care of the annoying bits like figure size, font size, and setting the correct font, with minimal overhead.
Author nathanaelbosch
Popularity
40 Stars
Updated Last
4 Months Ago
Started In
August 2022

TuePlots.jl

A Julia port of the tueplots Python package.

Stable Dev Build Status Coverage

TuePlots helps you create better plots for scientific publications. TuePlots does not try to make your plots "beautiful" - colors and line widths are up to you - but it takes care of the annoying bits like figure size, font size, and setting the correct font. Look at the following example:

The figure on the left is created with the CairoMakie default settings. Since the figure resolution does not fit the PDF page, it has to be rescaled in LaTeX and as a result font sizes are completely off. But with just a few lines of TuePlots.jl you get the result on the right, with correct fonts and figure sizes - you don't even need to do [width=\linewidth] in LaTeX anymore!

Installation

Install TuePlots directly with the Julia package manager:

julia> ]
(v1.7) pkg> add TuePlots

TuePlots.jl with CairoMakie.jl (recommended)

Using TuePlots with (Cairo)Makie is easy: Just create a Makie.Theme from one of the settings provided by TuePlots:

using CairoMakie, TuePlots, Random

data = cumsum(randn(Xoshiro(2), 4, 201), dims = 2)

# Create a Makie.Theme with correct font, fontsize, and figure size:
T = Theme(
    TuePlots.SETTINGS[:AISTATS];
    font = true,
    fontsize = true,
    figsize = true,
    single_column = true,
    thinned = true
)

with_theme(T) do
    fig = Figure()
    ax = Axis(fig[1, 1], xlabel = "Time", ylabel = "Quantity of interest")
    sp = series!(ax, data, labels = ["label $i" for i in 1:4])
    axislegend(ax)
    save("makie.pdf", fig, pt_per_unit = 1) # pt_per_unit is needed to ensure the correct sizes
end

Voilà! Now you can focus on the important things, like choosing the best color scheme for your plot.

TuePlots.jl with Plots.jl (experimental)

WARNING: This is still experimental and some features do not yet work correctly! For the best experience, use TuePlots with (Cairo)Makie.

To use TuePlots.jl with Plots.jl, you can let TuePlots generate keyword arguments for Plots.theme as follows:

using Plots, TuePlots, Random

data = cumsum(randn(Xoshiro(2), 4, 201), dims = 2)

theme(:default;
    TuePlots.get_plotsjl_theme_kwargs(
        TuePlots.SETTINGS[:AISTATS];
        fontsize = true,
        figsize = true,
        single_column = true,
    )...)

plot(data',
    label = permutedims(["label $i" for i in 1:4]),
    xlabel = "Time",
    ylabel = "Quantity of interest",
);
savefig("plotsjl.pdf")

Required Packages

Used By Packages

No packages found.