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

\usepackage{pgfplots}

\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}

\pgfplotscreateplotcyclelist{colorbrewer-blues}{
{blues1},
{blues2},
{blues3},
{blues4},
{blues5},
}


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 :

\begin{document}
\begin{tikzpicture}
\begin{axis}[
cycle list name=colorbrewer-blues,
no markers,
every axis plot/.append style=thick]
\end{axis}
\end{tikzpicture}
\end{document}


and my non-working code:

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

)
)


! 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

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}]


cycle_list_name = "colorbrewer-blues"


or

"cycle list name" = "colorbrewer-blues"


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

1 Like

Thanks Tamas. Kind of embarrassingly easy…

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 {
(1,2)
(2,4)
(3,8)
}
;
\end{axis}


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}
\definecolor{color1}{RGB}{86,180,233}
\definecolor{color3}{RGB}{0,158,115}
\definecolor{color4}{RGB}{240,228,66}
\definecolor{color5}{RGB}{0,114,178}
\definecolor{color6}{RGB}{213,94,0}
\definecolor{color7}{RGB}{204,121,167}

\pgfplotscreateplotcyclelist{colorbrewer-tamasgal}{
{color1},
{color2},
{color3},
{color4},
{color5},
{color6},
{color7}
}
""");

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

1 Like

you mean horizontally? yes, we could do this.

Yes, horizontally

1 Like