Quarto: Running a Julia notebook

quarto
julia
Author

Carol Willing

Published

June 4, 2023

This is based on the Quarto Julia docs.

Setup

  1. Install Julia for your operating system.

  2. Install IJulia. For this step, I use the Julia REPL. Enter pkg mode by pressing ] and enter: add IJulia. This installs the IJulia kernel into the .julia directory in your home directory.

  3. From the Julia REPL, start a notebook server and kernel:

using IJulia
notebook()

or alternatively install the Julia extension for VS Code.

Usage

  1. Create a new markdown file with the following front matter. The key item to include is jupyter: and the kernel to be used:
---
title: "Quarto - Julia notebook"
format: html
jupyter: julia-1.8
---
  1. From the command line, run quarto preview to start the preview server or Render in VS Code.
import Pkg; Pkg.add("Plots")
   Resolving package versions...
  No Changes to `~/.julia/environments/v1.8/Project.toml`
  No Changes to `~/.julia/environments/v1.8/Manifest.toml`

Parametric Plots

Plot function pair (x(u), y(u)). See Figure 1 for an example.

using Plots

plot(sin, 
     x->sin(2x), 
     0, 
     2π, 
     leg=false, 
     fill=(0,:lavender))
Figure 1: Parametric Plots

See Figure 2 for another example.

using Plots

plot(sin, 
     x->sin(4x), 
     0, 
     2π, 
     leg=false, 
     fill=(0,:pink))
Figure 2: Sin Plots

You should now see rendered charts with Julia.

VS Code

Here’s a rendering of the Julia document in VS Code.

Julia and Quarto in VS Code