PGFPlotsX.jl - custom color cycler?

I am trying to use a custom color cycler for all my plots in my thesis. In my LaTeX style document I defined some colours for testing, here is an example which I found on SO:


\definecolor{blues1}{RGB}{198, 219, 239}
\definecolor{blues2}{RGB}{158, 202, 225}
\definecolor{blues3}{RGB}{107, 174, 214}
\definecolor{blues4}{RGB}{49, 130, 189}
\definecolor{blues5}{RGB}{8, 81, 156}


And now I am struggling to get the cycle list name=colorbrewer-blues to be passed to the Axis. So this is the TeX code :

    cycle list name=colorbrewer-blues,
    no markers,
    every axis plot/.append style=thick]
\addplot {rnd*.5-.25};
\addplot {rnd*.5-0.5};
\addplot {rnd*.5-0.75};
\addplot+[orange,very thick]{rnd*.5+x*0.05-0.75};

and my non-working code:

@pgf GroupPlot(
    { group_style = { group_size="2 by 1" },
      legend_pos="north west",
      xlabel=raw"$\delta$ [deg]",
      cycle=raw"list name=colorbrewer-blues",
        PlotInc(Table(zenith.δ, zenith.λ ./ maximum(zenith.λ))),
        LegendEntry(raw"zenith scan")
        PlotInc(Table(azimuth.δ, azimuth.λ ./ maximum(azimuth.λ))),
        LegendEntry(raw"azimuth scan"),

PGFPlots of course complains about the bad syntax with

! Package pgfkeys Error: I do not know the key ‘/pgfplots/cycle’, to which you
passed ‘list name=colorbrewer-blues’, and I am going to ignore it. Perhaps you
misspelled it.

Can anyone help? I am still new to both PGFPlotsX.jl and PGFPlots in general, so sorry for this dumb question, I am sure I still did not grasp how both talk to each other :see_no_evil:

Ahm, it seems cycle_list=raw"name=colorbrewer-blues" is the correct one I guess, at least there is no error and everything is grey…

Edit: the corresponding line like this in the TeX output (checked with print_tex()), so it’s incorrect since it’s in curly brackets and not in square brackets:

\begin{groupplot}[group style={group size={2 by 1}}, no markers, legend pos={north west}, xlabel={$\delta$ [deg]}, cycle list={name=colorbrewer-blues}]

Please try

cycle_list_name = "colorbrewer-blues"


"cycle list name" = "colorbrewer-blues"

Please look at the docs, starting with “keywords can be entered”.

1 Like

Thanks Tamas. Kind of embarrassingly easy… :wink:

No worries. Do you think this is prominent enough in the docs, or we should emphasize it more, eg by giving it its own subsection? It is kind of key to using PGFPlotsX idiomatically.

I think it’s prominent enough and it was mainly my blindness/ignorance. I already was on the right track with the print_tex() helper function.

The only thing which may have helped to not overlook that is the formatting of the TeX output in the examples. Maybe it’s better to do some nesting instead of the long vertically scrollable lines?

I mean this one (although it might be better to leave the output of print_tex() as it is):

julia> print_tex(a)
\begin{axis}[axis background/.style={shade, top color={gray}, bottom color={white}}, ymode={log}]
        coordinates {

Btw. it’s still somewhat related. I could not figure out a good way to deal with the preamble. Currently I do:

preamble = split(raw"""
\pgfplotsset{every axis/.append style={
             label style={font=\small},
             tick label style={font=\small}  
\definecolor{color2}{RGB}{230, 159, 0}


push!(PGFPlotsX.CUSTOM_PREAMBLE, preamble...)

I can bury this into an include file but I also found that PGFPlotsX.CUSTOM_PREAMBLE_PATH which points to a custom_preamble.tex inside the source folder of the package. Is there any way to alter that path? I would like to reuse the same include I use for my thesis in the plotting scripts which produce the plots every time I do a make (or run the CI of the thesis-repo).

Edit: ah damn, forget it. I just found that it can be set via the environment variable PGFPLOTSX_PREAMBLE_PATH. I should sleep a few hours I guess :sweat_smile:

1 Like

you mean horizontally? yes, we could do this.

Yes, horizontally :smile:

1 Like