Reputation: 2330
In Julia's Plots
package, I can change the color of a surface plot like this:
plot(mySurface,st=:surface,c=:blues)
How can I change the default color gradient so that I don't have to put the c=:blues
every time?
(The relevant Plots doc page does not state how to modify the default.)
Upvotes: 3
Views: 1419
Reputation: 5583
See the tip from the Julia Plots documentation:
Tip: You can see the default value for a given argument with
default(arg::Symbol)
, and set the default value withdefault(arg::Symbol, value)
ordefault(; kw...)
. For example set the default window size and whether we should show a legend withdefault(size=(600,400), leg=false)
.
Hence, you can set the default you want with
default(c=:blues)
Though you probably want to set a new default for fillcolor
rather than seriescolor
or its alias c
since seriescolor
will also affect color of other type of plots and you probably would not want that.
default(fillcolor=:blues)
The default will work so long as you do not set any other default or restart your Julia session.
If you want your new default to work even after restarting Julia you might want to try Requires.jl
and your startup file (~/.julia/config/startup.jl
) with something like the following,
using Requires
@require Plots="91a5bcdd-55d7-5caf-9e0b-520d859cae80" Plots.default(fillcolor=:blues)
where 91a5bcdd-55d7-5caf-9e0b-520d859cae80
is the UUID of Plots.jl
package in the registry.
Upvotes: 2
Reputation: 344
I saw a possible solution here. https://github.com/JuliaPlots/Plots.jl/issues/87
with(c = :blue) do
plot!(rand(5))
plot!(rand(5))
end
Upvotes: 2
Reputation: 2718
You should either the palette
or the m
keyword as shown in the examples:
y = rand(100)
plot(0:10:100, rand(11, 4), lab="lines", w=3, palette=:grays, fill=0, α=0.6)
scatter!(y, zcolor=abs.(y .- 0.5), m=(:heat, 0.8, Plots.stroke(1, :green)), ms=10 * abs.(y .- 0.5) .+ 4, lab="grad")
Upvotes: 0