Skip to content

Plotting for publications. #897

@ma-laforge

Description

@ma-laforge

This "issue" is meant to help people who wish to generate plots destined for publications.

NOTE:

  • The API of Plots.jl is mostly designed to make interactive plotting quick & simple.
  • However, when targeting publications, one often needs to set more options to better control plot appearances.

Setting Defaults

I personally find it is easier to control the appearance of publication-plots by first setting the Plots.jl defaults:

using Plots

upscale = 8 #8x upscaling in resolution
fntsm = Plots.font("sans-serif", pointsize=round(10.0*upscale))
fntlg = Plots.font("sans-serif", pointsize=round(14.0*upscale))
default(titlefont=fntlg, guidefont=fntlg, tickfont=fntsm, legendfont=fntsm)
default(size=(800*upscale,600*upscale)) #Plot canvas size
default(dpi=300) #Only for PyPlot - presently broken

Please make sure to select the appropriate font size relative to the size of the plot canvas.

I also suggest to pick the same aspect ratio for the plot canvas size as will be used for the final image dimensions in the publication.

IMPORTANT:

  • For most GUI-enabled backends, the figure size does not affect what is displayed on screen. The on-screen figure size typically under user control (i.e. when the window is resized).
  • If implemented correctly, the dpi value should only affect the number of pixels used to generate pixel-based plot images (ex: .png files). It should not affect line thicknesses relative to total image size.
  • If (most likely) the dpi feature is not implemented for your backend, then you will need to manually control the resultant "DPI" by up-scaling all the dimensions, widths, etc. See upscale variable.

Controlling Line Appearances:

When generating publication-plots, one should also exhert more explicit contol over how datasets are added to a plot:

plot!(x, y, linestyle=:solid, linealpha=0.5, linewidth=4*upscale, linecolor=:red)

One might also want to control the line thicknesses used to frame the plot/axes, or used by the grids.

  • Unfortunately, I do not know how to do this. Someone please comment.

Embedding images in your publication

Most publishing suites will allow users to specify the physical size (ex: in cm x cm) of the image being added. So, as long as the plot was generated using the appropriate aspect ratio, there should be no issues.

The same is true for LaTeX:

\includegraphics[width=4cm,height=3cm]{./images/myimage}

More on Fonts

Warning: Some vector-based file formats (ex: .svg, .eps) might not properly embed font definitions within the image. This might cause issues where the publisher will have to substitute the desired font with a different one (or drop text all-together).

To avoid this issue, one can export to a pixel-based format (ex: .png, or .tiff) at the cost of image quality/file size. In this case, please ensure your resolution (i.e. total pixel count) is sufficiently large to maintain image quality.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions