logo

How to Add a Main Title in Julia Subplots 📂Julia

How to Add a Main Title in Julia Subplots

Overview

When drawing figures in Julia, to apply a title to all subplots, one should use plot_title instead of title1. This is because the arguments of the outermost plot() function, in the case of a plot with subplots like

plot(
    plot1, plot2, ...
)

inherit properties to the inner subplots. To clearly distinguish between them, title and plot_title are used separately.

Code

plot(p1, p2, title = "Two Plots")

Alt text

As you can see, using title = "Two Plots" applies the title to all subplots.

plot(p1, p2, plot_title = "Two Plots")

Alt text

plot_title = "Two Plots" applies just one title to the entire figure, as can be seen.

Entire code

using Plots

p1 = scatter(rand(100))
p2 = histogram(rand(100))

plot(p1, p2, title = "Two Plots")
plot(p1, p2, plot_title = "Two Plots")

Environment

  • OS: Windows
  • julia: v1.8.5