
¿Cómo puedo cambiar el color predeterminado de la plantilla de gráfico al dorso?
encontré una lista de colores
Mi MWE:
\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.16}
\begin{document}
\begin{tikzpicture}
\pgfplotsforeachungrouped \X in {1,...,9}
{\ifnum\X=1
\edef\mylst{Testing1}
\else
\edef\mylst{\mylst,Testing\X}
\fi}
\begin{axis}[symbolic x coords/.expanded=\mylst,
ylabel=Number,
enlargelimits=0.05,
x tick label style={anchor=north west,rotate=-30},
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ybar,
]
\addplot
coordinates {(Testing1,9) (Testing2,4)
(Testing3,4) (Testing4,1) (Testing5,1) (Testing6,8) (Testing7,1) (Testing8,1) (Testing9,1)};
\addplot
coordinates {(Testing1,3) (Testing2,5)
(Testing3,5) (Testing4,4) (Testing5,5) (Testing6,7) (Testing7,0) (Testing8,0) (Testing9,0)};
\legend{Series 1, Series2}
\end{axis}
\end{tikzpicture}
\end{document}
Respuesta1
Los colores predeterminados no tienen nada que ver con los que aparecen al dorso, pero se almacenan en listas de ciclos. La lista de ciclos relevantes para ybar
(que es la misma para xbar
) se puede encontrar en la p. 86 del manual v1.16,
Puedes cambiarlo para obtener, por ejemplo
\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.16}
\pgfplotsset{
/pgfplots/bar cycle list/.style={/pgfplots/cycle list={
{OliveGreen,fill=OliveGreen!30!white,mark=none},
{Plum,fill=Plum!30!white,mark=none},
{cyan!60!black,fill=cyan!30!white,mark=none},
{black,fill=gray,mark=none},
},
},
}
\begin{document}
\begin{tikzpicture}
\pgfplotsforeachungrouped \X in {1,...,9}
{\ifnum\X=1
\edef\mylst{Testing1}
\else
\edef\mylst{\mylst,Testing\X}
\fi}
\begin{axis}[symbolic x coords/.expanded=\mylst,
ylabel=Number,
enlargelimits=0.05,
x tick label style={anchor=north west,rotate=-30},
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ybar,
]
\addplot
coordinates {(Testing1,9) (Testing2,4)
(Testing3,4) (Testing4,1) (Testing5,1) (Testing6,8) (Testing7,1) (Testing8,1) (Testing9,1)};
\addplot
coordinates {(Testing1,3) (Testing2,5)
(Testing3,5) (Testing4,4) (Testing5,5) (Testing6,7) (Testing7,0) (Testing8,0) (Testing9,0)};
\legend{Series 1, Series2}
\end{axis}
\end{tikzpicture}
\end{document}
Aquí cargué xcolor
con la dvipsnames
opción para incluir tus colores elegantes, también puedes usarla \PassOptionsToPackage{dvipsnames}{xcolor}
antes \usepackage{pgfplots}
ya que se carga xcolor
de todos modos.
Alternativamente, puede pasar las opciones directamente a \addplot
:
\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.16}
\begin{document}
\begin{tikzpicture}
\pgfplotsforeachungrouped \X in {1,...,9}
{\ifnum\X=1
\edef\mylst{Testing1}
\else
\edef\mylst{\mylst,Testing\X}
\fi}
\begin{axis}[symbolic x coords/.expanded=\mylst,
ylabel=Number,
enlargelimits=0.05,
x tick label style={anchor=north west,rotate=-30},
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ybar,
]
\addplot[fill=ForestGreen!30,draw=ForestGreen]
coordinates {(Testing1,9) (Testing2,4)
(Testing3,4) (Testing4,1) (Testing5,1) (Testing6,8) (Testing7,1) (Testing8,1) (Testing9,1)};
\addplot[fill=RoyalPurple!30,draw=RoyalPurple]
coordinates {(Testing1,3) (Testing2,5)
(Testing3,5) (Testing4,4) (Testing5,5) (Testing6,7) (Testing7,0) (Testing8,0) (Testing9,0)};
\legend{Series 1, Series2}
\end{axis}
\end{tikzpicture}
\end{document}
Puedes utilizar cualquiera de los colores de tu lista, por supuesto.