Any package for plots in style of Scientific Journals?

Hi, I am preparing plots for submission to a professional scientific journal (specifically, The Astrophysical Journal). Are there any Julia packages designed to make the plots look appropriate for the style of a journal like this? (I could try hunting & seeking over all of the plot options, but I wonder if someone has put together a package like this; my plots look vaguely amateurish so far.)

In the past, I have always exported my data and used an external plotting program (like OriginPro) to do the plots; but that would take a very large amount of needless work in this case. I would rather have an in-Julia option, since I’ve done my calculations in Julia.

(And yes, I will include a citation to Julia in the paper.)

Thank you!

Are you writing your paper in LaTeX? I use PythonPlot.jl, which lets you use LaTeX in plot text, such as axis labels. Which is nice, because you can then use the same fonts in the plots and the main text. And LLMs work very well; they can help you to create and format the plots.

But there are many other options. The key point is to use vector graphics, so save your plots as PDF before including them in your paper.

I tell my students to use GitHub - aenarete/ControlPlots.jl: Easy to use plotting for control engineers and students because it is easy for beginners. The README might give you some inspiration.

But there are many other options. CairoMakie | Makie probably also works well.

Shameless advertising: My last paper with many nice plots.

9 Likes

GMT (reproducible here via GMT.jl) has over 14 k citations in scientific journals.

1 Like

I looked at the first five papers in the current. number and for the most part the plots are not highly finished. The Makie ecosystem should be able to produce any of them without too much trouble. If you can provide some fake (or real) data and an example of the output you are aiming for, I can show you how that can be done.

3 Likes

Usually journals provide templates for the document itself, like LaTeX class or plain template. But I haven’t seen a template for figures. There is just a list of requirements, typically the size of labels, legends etc., usage of grid or requirement that the figure should be readable in black-and-white print. Usually the figures need to be send as vector graphics (pdf, svg) or good quality PNG.

All other stuff is up to you, and any decent plotting library should do the trick. I’ve been using extensively matplotlib in the past (in Julia accessible as PythonPlot), then moved to GR, next Plots.jl, and finally settled at Makie. In the latter you can define a theme, that matches requirements and your taste (Themes | Makie). I use something like this

my_theme = Theme(
                      Axis = (
                          xlabelsize = 28, 
                          xticklabelsize = 24, 
                          xminorticks = IntervalsBetween(5), 
                          xminorticksvisible = true, 
                          xgridvisible = false,
                          ylabelsize = 28, 
                          yticklabelsize = 24, 
                          ygridvisible = false, 
                          yminorticks = IntervalsBetween(5), 
                          yminorticksvisible = true,
                      ),
                      Legend = (
                          labelsize = 24,
                      ),
                      Scatter = (
                           markersize = 16,
                       ),
                        Lines = (linewidth=2.0,
                      ),
                   )

Of course sometimes the plots need to be individually fine-tuned, but that is kind of a common starting point.

There is also a MakiePublication (GitHub - liuyxpp/MakiePublication.jl: A Julia package for producing publication quality figures based on Makie.jl.) package with themes for selected publishers. Maybe you will find them useful.

10 Likes

All the major Julia plotting packages can produce publication quality plots. Includes Makie, Plots (with a number of backends, including many of the other packages mentioned, GR, PyPlot, PgfplotsX (that does latex if that is what you need), etc etc.

2 Likes

The Makie.org website has very good tutorials and how-to’s. For example, this link shows how to create figures with specific figure sizes, DPI values, and font sizes.

2 Likes

Hi everyone, thank you for all of your great suggestions!
Makie (CairoMakie?) seems like the clear winner here, I’m going to try that first.
It is especially exciting that they have specific styles for particular journals/journal organizations (in the link in kmiernik’s post). Not the exact journal I’m looking for, but hopefully close enough.
If I have any further questions after trying Makie, I’ll post again soon. Thanks!

1 Like

Hi technocrat, thanks for your offer of providing specific code as Makie pointers. I may take you up on it in a week or so, if I can’t get it to work on my own. Thanks again!

1 Like

You may also want to look at MakiePublication, which makes it just a bit tidier to work with themes, especially if you are going to make different versions for the journal and presentations.

4 Likes

For plot quality, I would use TikZ/pgfplots, for which there’s a package, PgfPlotsX.jl, or as a backend from other plotting packages, at least Plots.jl.

For optimal quality and consistency, this is the best solution, but there is a learning curve if you want to achieve consistent styling and size throughout the document. And you may find yourself fiddling more with the plots than you were planning to.

4 Likes

Thanks tobydriscoll, I’ll definitely check that out along with Makie.

Thanks for the suggestion, DNF. I’m going to try Makie first, since everyone has been recommending that package. But if it doesn’t look right, I’ll jump on the learning curve for TikZ.

Hi again, just starting out with Makie, all basic commands like the following result in an error:

using MakiePublication
using CairoMakie
#
xTest = [0.9,1.8,3.1,4.0,5.1]
yTest = [12.5,32.7,22.2,55.3,33.5]
#
plot_tester = Makie.scatter(xTest, yTest)
with_theme(plot_tester, theme_aps())

I get the error:
ERROR: MethodError: objects of type Makie.FigureAxisPlot are not callable

It doesn’t help if I replace Makie.scatter with MakiePublication.scatter or CairoMakie.scatter or just scatter.

(My program starts with using Plots – I need to use that – so maybe there’s a conflict somewhere.)

You need a FigureAxisPlot object to be decorated. Unfortunately the return of scatter is not that type. Follow the doc of MakiePublication, you can do following instead:

with_theme(theme_aps()) do
    Makie.scatter(xTest, yTest)
    current_figure()
end
1 Like

I did get that basic plot style working. Thanks!
But ultimately I’m trying to do something complicated like this, in theme_aps() style. (It seems like I need to define a Makie plotting function, and I’m getting errors every time.)
Here’s an example with all kinds of stuff thrown in:

FlatZeroLineSegment(y) = 0.0
#
MyPlotName = scatter(Array1, Array2,
    yerr = Array3, markerstrokecolor = "red", markerstrokewidth = 0.3, 
    xlim = (1.0, 5.0), ylim = (10.0, 20.5),
    title = "My Plot Title", titlefontsize = 11,
    xlabel ="my x Axis", ylabel = "my y Axis",
    label = "DataPoints1", color = "orange", markersize = 1.5, markershape = :diamond);
#
    scatter!(MyPlotName , Array4, Array5,
    yerr = Array6, markerstrokecolor = "pink", markerstrokewidth = 0.7,
    label = "DataPoints2", color = "darkgreen", markersize = 2, markershape = :plus);
#
    plot!(MyPlotName, vline!([2.5], linewidth=2.0, linecolor=:green, label = false));
#
    plot!(MyPlotName, FlatZeroLineSegment, 1.0, 5.0, color="red", linewidth=1.0, label = false);
#
    annotate!(1.5, 14.5, text("Hi", :black, :bottom, 8));
display(MyPlotName)

(I suppose some of these settings may be over-ridden by the aps theme.)

For more complicated usecase, consider using Figure and Axis API of Makie. Like

fig = Figure()
ax = Axis(fig[1, 1])

Makie.scatter!(ax, ...)

Then you can simply pass fig to MakiePublication such as with_theme(fig, theme_aps())

Edit: sorry, copying from Makie doc and forgot to rename variable, f → fig.

The ax = Axis(f[1, 1]) command results in the error:
ERROR: UndefVarError: `f` not defined in `Main`
As a result, at the end I get:
ERROR: MethodError: objects of type Figure are not callable

Basically, I don’t understand this syntax, so I don’t know what’s going on with it.

Also, I have to assume that all the complicated commands I included in my example above would get stuffed into the Makie.scatter!(ax, ...) command, and I don’t know if they would all work in there. (Could you provide a somewhat more detailed example?) Thank you.

Just remember you should provide MakiePublication the FigureAxisPlot object, which can be generated by explicitly calling Figure() or implcitly obtaining from current figure whatever it is via CurrentFigure().

I’d suggest investing 1 hour to learn Makie basics from Makie’s doc, say Getting started | Makie.

2 Likes

OK, that “Getting Started” primer is very useful (the readme I found earlier was less helpful).
Thanks for correcting your typo, now I understand the general syntax.
I can make plots now, but it is super-fiddly (everything has a different keyword to be adjusted).
But the result looks good!

1 Like