Specifying Background Color in Julia Plots
Overview
The keywords related to the background color of figures in Plots.jl
are as follows.
Keyword Name | Function |
---|---|
background_color , bg_color | Specify the color of the overall background |
background_color_outside , bg_color_outside | Specify the color of the area outside where the graph is drawn |
background_subplot , bg_subplot | Specify the color of the area where the graph is drawn |
background_inside , bg_inside | Specify the color of the area where the graph is drawn, excluding the legend |
Code
The keyword to specify the background color is background_color(=bg_color)
. It sets the color of the legend, the area where the graph is drawn, and all the background to the entered value.
plot(rand(10), bg_color = :tomato)
The keyword to specify the color outside the area where the graph is drawn is background_color_outside(=bg_color_outside)
.
plot(rand(10), bg_color_outside = :palegreen)
The keyword to specify the color of the area where the graph is drawn is background_subplot(=bg_subplot)
.
plot(rand(10), bg_subplot = :violet)
The keyword to specify the color of the area where the graph is drawn, excluding the legend, is background_inside(=bg_inside)
.
plot(rand(10), bg_inside = :brown4)
Sub Plots
When there are multiple sub plots, it is necessary to set the color using bg_subplot
or bg_inside
to maintain each background color when combined into an overall plot.
p₁ = plot(rand(10), bg_subplot = :tomato)
p₂ = scatter(rand(10), bg_inside = :yellow)
p = plot(p₁, p₂)
Environment
- OS: Windows11
- Version: Julia 1.9.4, Plots v1.39.0