Plots.jl Quick Reference

by Martin D. Maas, Ph.D

Quick reference guide on how to get started with Plots.jl

There are many visualization libraries to choose from in the Julia ecosystem (see below on this page). Arguably, the Plots.jl library is the standard plotting tool in the Julia ecosystem. It in turn provides a single API to access multiple “backends”, which include:

BackendDocumentation
Matplotlib (Pyplot)Pyplot
PlotlyPlotly
GRGR

To select one of these different backends, we simply call the corresponding command. For example, to load Plots.jl and use the GR backend (which is the default), we would do:

using Plots
gr()

You can check the official documentation of Plots.jl here.

While the Tutorial section of the documentation can help you get started, I found it a little overwheliming at first sight. Over time, I ended up compiling a list of the properties I most frequently use, which I share in this page.

Simple Plots with Plots.jl and GR

The simplest kind of plots are line plots, which can be produced given at least two vectors x and y.

using Plots
gr()

x = 0:0.05:1;
y = sin.(2π*x);
plot(x,y)

Julia Line Plot

Other Visualization Packages

There are multiple plotting packages for Julia worth checking:

PackageDescriptionExamplesTutorial
StatsPlots.jlA drop-in replacement for Plots.jl that contains specialized statistical plotting functionalities.StatsPlots.jl repositoryPlots.jl docs
Makie.jlA high-performance plotting ecosystem with OpenGL, Cairo and WebGL backends. It’s great for publication-quality plotting, but can be a little bit slow to load and useDocs
VegaLiteA Julia wrapper for the Vega-Lite library. Great for interactive graphics.Docs.
GadflyBased on the R package gglot2, very well suited for statistics and machine learning.Docs

Detailed documentation can be found in each package, and in the referenced tutorials and examples pages.