How to change default color theme in Makie?

:frowning: tried belows, but no one works.

using CairoMakie, LaTeXStrings

set_theme!(color = :blue)
set_theme!(colors = :darktest)
set_theme!(colormap = :Hiroshige) # https://docs.makie.org/stable/api/index.html#Makie
set_theme!(colormap = :darktest)
set_theme!(colormaps = :darktest)
set_theme!(palette = :darktest)
set_theme!(palette = (patchcolor = [:red, :green, :blue, :yellow, :orange, :pink],)) # https://docs.makie.org/stable/documentation/theming/index.html#palettes
set_theme!(palette = (; patchcolor = cgrad(:Egypt, alpha=0.65))) # https://docs.makie.org/stable/api/index.html#Makie

f = Figure()
ax = Axis(f[1,1])
for _ in 1:10
    lines!(ax, rand(5))
end
f

ps. I asked about set_theme! with font issue last week and feel confusing how I use it.

Where I could learn about the function? API documentation is not helpful :frowning: :

Environment

  • julia 1.8.5
  • CairoMakie v0.10.2
  • windows 11

Try this

using CairoMakie, LaTeXStrings

set_theme!(Theme(palette=(color=[:red, :blue, :green],),))

f = Figure()
ax = Axis(f[1, 1])
for _ in 1:3
    lines!(ax, rand(5))
end
f

For reference, I have a very basic library (which I intend to expand to do scientific animations), where I have a few themes created that might be a good reference for you. In this file I define the themes and in this other file I make some basic plots.

Hopefully this clarifies it.

This also works

set_theme!(palette=(color=[:red, :blue, :green],))

Although if you remove the last comma you will get a conversion error.

Thank you but sadly I guess I canā€™t use Makie based libraries. I wonder how do you learn and used to it. Even in your just two answers, I donā€™t get what exactly they different and why my trials were wrong. Structure Theme seems to be essential, but not in some examples as you shown. Maybe I can overcome these some problems by asking but I canā€™t write my own codes if I donā€™t understand the fundamental grammer of Makie.

Maybe have a look at how the default theme is defined:

I get that itā€™s frustrating to try many things and nothing works, however, Makie would be magic if it just did whatever people think of trying :slight_smile: Yes, everything could be documented better, but given our limited time, we canā€™t do that at once for every last aspect of the library (itā€™s pretty big).

There are several ā€œpalettesā€ in the default theme, each of these is meant to be used by Cyclers. And there are both color and patchcolor entries because sometimes people want different defaults for polygons (usually because they want them slightly transparent). Lines, scatter, text etc all use color, pretty much only poly and derivations of it like barplot use patchcolor.

1 Like

Exactly how youā€™re doing it, asking people if you canā€™t figure it out yourself using the documentation and the source code. And ideally, contributing back to the documentation afterwards, this way for the next person after you everything will be a little easier to understand.

2 Likes