This is the way:
Use the default()
function like so
using Plots
default(titlefont = (20, "times"), legendfontsize = 18, guidefont = (18, :darkgreen), tickfont = (12, :orange), guide = "x", framestyle = :zerolines, yminorgrid = true)
plot([sin, cos], -2π, 2π, label = ["sin(θ)" "cos(θ)"], title = "Trigonometric Functions", xlabel = "θ", linewidth = 2, legend = :outertopleft)
Taken from the documentation here. I know the Plots.jl docs can be a bit tricky to navigate due to their size, but in this case I just typed default
into the doc search box.
Note that when using the default
function you don't supply the keyword args in subsequent calls to plot
, unless of course you want to change away from your newly specified defaults.
Since you are asking for a way to save defaults across sessions, I will also point you to this additional tip from the installation docs:
You can override standard default values in your ~/.julia/config/startup.jl
file: PLOTS_DEFAULTS = Dict(:markersize => 10, :legend => false, warn_on_unsupported = false)
So here you are defining the new defaults as a dictionary which is used as an environment variable, which allows setting defaults before loading Plots (and thus without having the default
function available).
defs
in a file, so that I can just load it? For example, in jupyter/python/matplotlib, I can put a file in~/.matplotlib/stylelib/mystyle.mplstyle
. I can just runplt.style.use(mystyle)
to use it. – Diamonddiamondback