我想在 pgfplots 中使用colorbrewer
循环列表Set1-5
。这通常以红色开始,然后是蓝色。但是,我想使用蓝色作为第一种颜色,红色作为第二种颜色,所以基本上交换前两种颜色。
我知道,我可以针对一个特定的图执行此操作,但我想针对我的整个文档执行此操作,例如通过定义基于的新循环列表Set1-5
。
有没有办法做到这一点?
任何帮助,将不胜感激!
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.16,
every axis/.append style={grid, width=0.98\textwidth, height=8cm},
grid style={densely dotted, thick},
every axis plot/.append style={thick},
label style={},
ticklabel style={
/pgf/number format/.cd,
use comma,
1000 sep = {},
/tikz/.cd
},
legend cell align=left,
legend pos={north east},
}
\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{colorbrewer}
\usepgfplotslibrary{groupplots}
\pgfplotsset{cycle list/Set1-5}
答案1
我想,最简单的方法是cycle list
利用该indices of colormap
功能创建新的,将第一个切换为颜色。
% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\pgfplotsset{
cycle list/Set1-5,
% ---------------------------------------------------------------
% (this is just to make things simple)
% copied from the manual
cycle from colormap manual style/.style={
x=3cm,y=10pt,ytick=\empty,
colorbar style={x=,y=,ytick=\empty},
point meta min=0,point meta max=1,
stack plots=y,
y dir=reverse,colorbar style={y dir=reverse},
every axis plot/.style={line width=2pt},
legend entries={0,...,20},
legend pos=outer north east,
},
% ---------------------------------------------------------------
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
cycle from colormap manual style,
cycle list={[indices of colormap={1,0,2,3,4 of Set1-5}]},
]
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\end{axis}
\end{tikzpicture}
\end{document}