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) #
set_theme!(colormap = :darktest)
set_theme!(colormaps = :darktest)
set_theme!(palette = :darktest)
set_theme!(palette = (patchcolor = [:red, :green, :blue, :yellow, :orange, :pink],)) #
set_theme!(palette = (; patchcolor = cgrad(:Egypt, alpha=0.65))) #

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

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: :


  • 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))

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.